Register context restoration based on rename register recovery

ABSTRACT

A load request to restore a plurality of architected registers is obtained. Based on obtaining the load request, one or more architected registers of the plurality of architected registers are restored. The restoring uses a snapshot that maps architected registers to physical registers to replace one or more physical registers currently assigned to the one or more architected registers with one or more physical registers of the snapshot corresponding to the one or more architected registers.

BACKGROUND

One or more aspects relate, in general, to processing within a computingenvironment, and in particular, to facilitating such processing.

Computer programs often call functions to provide particular operations,such as print, various mathematical operations, etc. The program callingthe function is referred to as a caller, and the called function isreferred to as the callee. Many of these functions are extremely short,either due to their net static length (i.e., the functions do notinclude many instructions), or their short dynamic length (e.g., due toan early-out condition).

Short functions, like any other functions, store callee-saved registersthat they modify on a stack as part of the function's prolog and restorethem as part of the epilog. The stack, also referred to as a call stack,is used by a computer program to store information about activefunctions of the computer program. Similarly, callers to such functionssave caller-saved registers on the stack as part of the function's callsequence, and restore them upon the return, if the values live acrossthe function call. Saving these registers is a significant expense ofcalling a function.

Further, for short functions, the expense associated with saving andthen restoring these registers is even higher, since the restore canonly occur after the save has completed, and that is not guaranteed tooccur. Under these circumstances, additional penalties, such asload-hit-store and forwarding penalties may be incurred.

SUMMARY

Shortcomings of the prior art are overcome and additional advantages areprovided through the provision of a computer program product forfacilitating processing within a computing environment. The computerprogram product comprises a storage medium readable by a processingcircuit and storing instructions for performing a method. The methodincludes, for instance, obtaining, by a processor, a load request torestore a plurality of architected registers; and restoring, based onobtaining the load request, one or more architected registers of theplurality of architected registers. The restoring uses a snapshot thatmaps architected registers to physical registers to replace one or morephysical registers currently assigned to the one or more architectedregisters with one or more physical registers of the snapshotcorresponding to the one or more architected registers. By using thesnapshot to restore the one or more architected registers, performancemay be improved by avoiding memory accesses to perform the restoring.

In one aspect, based on obtaining the load request, a determination ismade as to whether a snapshot corresponding to the one or morearchitected registers is available. The restoring is performed using thesnapshot, based on the determining indicating the snapshot is available.

In a further aspect, the one or more architected registers are restoredby loading values from memory into the one or more architectedregisters, based on the determining indicating a snapshot correspondingto the one or more architected registers is unavailable.

As one example, the determining includes using a snapshot stack todetermine whether a snapshot corresponding to the one or morearchitected registers is available.

The snapshot stack includes, for instance, a plurality of entries. Inone example, an entry of the snapshot stack includes a snapshotidentifier identifying the snapshot. In further examples, the entry ofthe snapshot stack includes additional information including at leastone selected from a group consisting of: an address in memory ofcontents of the one or more architected registers, an indication of theone or more architected registers associated with the snapshot, and avalidity indicator indicating whether the snapshot is valid.

In a further aspect, the snapshot is created to save a mapping of theone or more physical registers to the one or more architected registers.

The creating the snapshot is performed, in one example, based onobtaining a save request requesting a saving of the one or morearchitected registers.

As an example, the load request includes a load multiple instruction,and the save request includes a store multiple instruction.

Further, in one embodiment, the one or more architected registers arerestored absent a copying of values for the one or more architectedregisters from memory.

Methods and systems relating to one or more aspects are also describedand claimed herein. Further, services relating to one or more aspectsare also described and may be claimed herein.

Additional features and advantages are realized through the techniquesdescribed herein. Other embodiments and aspects are described in detailherein and are considered a part of the claimed aspects.

BRIEF DESCRIPTION OF THE DRAWINGS

One or more aspects are particularly pointed out and distinctly claimedas examples in the claims at the conclusion of the specification. Theforegoing and objects, features, and advantages of one or more aspectsare apparent from the following detailed description taken inconjunction with the accompanying drawings in which:

FIG. 1A depicts one example of a computing environment to incorporateand use one or more aspects of the present invention;

FIG. 1B depicts further details of a processor of FIG. 1A, in accordancewith one or more aspects of the present invention;

FIG. 1C depicts further details of one example of an instructionexecution pipeline used in accordance with one or more aspects of thepresent invention;

FIG. 1D depicts further details of one example of a processor of FIG.1A, in accordance with an aspect of the present invention;

FIG. 2A depicts one example of storing caller-saved registers, inaccordance with an aspect of the present invention;

FIG. 2B depicts one example of storing callee-saved registers, inaccordance with an aspect of the present invention;

FIG. 3 depicts one example of a mapping of architected registers tophysical registers, in accordance with an aspect of the presentinvention;

FIG. 4A depicts one example of processing associated with a bulk saverequest, in accordance with an aspect of the present invention;

FIG. 4B depicts one example of processing associated with a bulk restorerequest, in accordance with an aspect of the present invention;

FIG. 5A depicts one example of a register rename table, a plurality ofsnapshots, and a physical rename file used in accordance with one ormore aspects of the present invention;

FIG. 5B is a further example of a register rename table, a plurality ofsnapshots, and a physical rename file used in accordance with one ormore aspects of the present invention;

FIG. 5C pictorially depicts one example of rolling back a snapshot, inaccordance with an aspect of the present invention;

FIG. 5D pictorially depicts another example of rolling back a snapshot,in accordance with an aspect of the present invention;

FIG. 6 depicts one example of a snapshot stack used in accordance withone or more aspects of the present invention;

FIG. 7A depicts one example of a Spill Multiple instruction, inaccordance with an aspect of the present invention;

FIG. 7B depicts one example of a Reload Multiple instruction, inaccordance with an aspect of the present invention;

FIG. 8A depicts another example of processing associated with a bulkrestore request, in accordance with an aspect of the present invention;

FIG. 8B depicts yet another example of processing associated with a bulkrestore request, in accordance with an aspect of the present invention;

FIG. 9 pictorially depicts one example of reusing a snapshot, inaccordance with an aspect of the present invention;

FIGS. 10A-10E depict examples of processing associated with managingrestoration snapshots, in accordance with one or more aspects of thepresent invention;

FIG. 10F depicts one example of performing recovery using sharedsnapshots for recovery and/or restoration, in accordance with an aspectof the present invention;

FIGS. 11A-11C depict embodiments of checking for memory changes andoptionally recovering, in accordance with one or more aspects of thepresent invention;

FIG. 12 depicts one example of processing associated with mismatchedSpill Multiple/Reload Multiple pairs, in accordance with an aspect ofthe present invention;

FIG. 13A depicts one example of entries in a data cache with associatedindicators, in accordance with an aspect of the present invention;

FIGS. 13B-13D depict examples of processing associated with theindicators depicted in FIG. 13A, in accordance with one or more aspectsof the present invention;

FIGS. 14A-14B depict examples of processing associated with registerrestoration, in accordance with one or more aspects of the presentinvention;

FIG. 15A depicts an example of processing associated with transactionalmemory and restoration, in accordance with one or more aspects of thepresent invention;

FIG. 15B depicts one example of a Transaction Begin instruction, inaccordance with one or more aspects of the present invention;

FIGS. 15C-15E depict aspects of processing associated with transactionalmemory and restoration, in accordance with one or more aspects of thepresent invention;

FIGS. 16A-16D depict examples of techniques used to track memorychanges, in accordance with one or more aspects of the presentinvention;

FIG. 17 depicts one example of handling a restoration request, inaccordance with an aspect of the present invention;

FIGS. 18A-18C depict examples of processing associated with contextswitches, in accordance with one or more aspects of the presentinvention;

FIG. 19A depicts one example of processing associated with managingsnapshots based on executing a Transaction Begin instruction, inaccordance with an aspect of the present invention;

FIG. 19B depicts one example of processing associated with a registersave indication, in accordance with an aspect of the present invention;

FIGS. 20A-20B depict examples of processing associated with coalescingstore/load instructions, in accordance with one or more aspects of thepresent invention;

FIG. 21A depicts one example of a store queue that includes write backlogic, used in accordance with an aspect of the present invention;

FIGS. 21B-21C depict examples of write back logic processing, inaccordance with one or more aspects of the present invention;

FIG. 22A depicts one example of a recovery buffer, in accordance with anaspect of the present invention;

FIG. 22B depicts one example of a processor that includes a recoverybuffer, in accordance with an aspect of the present invention;

FIGS. 23A-23B depict examples of processing associated with registerallocation requests, in accordance with one or more aspects of thepresent invention;

FIGS. 24A-24B depict one example of an aspect of facilitating processingwithin a computing environment, in accordance with an aspect of thepresent invention;

FIG. 25A depicts another example of a computing environment toincorporate and use one or more aspects of the present invention;

FIG. 25B depicts further details of the memory of FIG. 25A;

FIG. 26 depicts one embodiment of a cloud computing environment; and

FIG. 27 depicts one example of abstraction model layers.

DETAILED DESCRIPTION

In accordance with one or more aspects, a capability is provided tooptimize the saving and restoring of registers on function calls,thereby improving processing and reducing costs associated therewith. Inone example, the capability uses register renaming for thesaving/restoring.

One embodiment of a computing environment to incorporate and use one ormore aspects of the present invention is described with reference toFIG. 1A. In one example, the computing environment is based on thez/Architecture, offered by International Business Machines Corporation,Armonk, N.Y. One embodiment of the z/Architecture is described in“z/Architecture Principles of Operation,” IBM Publication No.SA22-7832-10, March 2015, which is hereby incorporated herein byreference in its entirety. Z/ARCHITECTURE is a registered trademark ofInternational Business Machines Corporation, Armonk, N.Y., USA.

In another example, the computing environment is based on the PowerArchitecture, offered by International Business Machines Corporation,Armonk, N.Y. One embodiment of the Power Architecture is described in“Power ISA™ Version 2.07B,” International Business Machines Corporation,Apr. 9, 2015, which is hereby incorporated herein by reference in itsentirety. POWER ARCHITECTURE is a registered trademark of InternationalBusiness Machines Corporation, Armonk, N.Y., USA.

The computing environment may also be based on other architectures,including, but not limited to, the Intel x86 architectures. Otherexamples also exist.

As shown in FIG. 1A, a computing environment 100 includes, for instance,a computer system 102 shown, e.g., in the form of a general-purposecomputing device. Computer system 102 may include, but is not limitedto, one or more processors or processing units 104 (e.g., centralprocessing units (CPUs)), a memory 106 (referred to as main memory orstorage, as examples), and one or more input/output (I/O) interfaces108, coupled to one another via one or more buses and/or otherconnections 110.

Bus 110 represents one or more of any of several types of busstructures, including a memory bus or memory controller, a peripheralbus, an accelerated graphics port, and a processor or local bus usingany of a variety of bus architectures. By way of example, and notlimitation, such architectures include the Industry StandardArchitecture (ISA), the Micro Channel Architecture (MCA), the EnhancedISA (EISA), the Video Electronics Standards Association (VESA) localbus, and the Peripheral Component Interconnect (PCI).

Memory 106 may include, for instance, a cache 120, such as a sharedcache, which may be coupled to local caches 122 of processors 104.Further, memory 106 may include one or more programs or applications130, an operating system 132, and one or more computer readable programinstructions 134. Computer readable program instructions 134 may beconfigured to carry out functions of embodiments of aspects of theinvention.

Computer system 102 may also communicate via, e.g., I/O interfaces 108with one or more external devices 140, one or more network interfaces142, and/or one or more data storage devices 144. Example externaldevices include a user terminal, a tape drive, a pointing device, adisplay, etc. Network interface 142 enables computer system 102 tocommunicate with one or more networks, such as a local area network(LAN), a general wide area network (WAN), and/or a public network (e.g.,the Internet), providing communication with other computing devices orsystems.

Data storage device 144 may store one or more programs 146, one or morecomputer readable program instructions 148, and/or data, etc. Thecomputer readable program instructions may be configured to carry outfunctions of embodiments of aspects of the invention.

Computer system 102 may include and/or be coupled toremovable/non-removable, volatile/non-volatile computer system storagemedia. For example, it may include and/or be coupled to a non-removable,non-volatile magnetic media (typically called a “hard drive”), amagnetic disk drive for reading from and writing to a removable,non-volatile magnetic disk (e.g., a “floppy disk”), and/or an opticaldisk drive for reading from or writing to a removable, non-volatileoptical disk, such as a CD-ROM, DVD-ROM or other optical media. Itshould be understood that other hardware and/or software componentscould be used in conjunction with computer system 102. Examples,include, but are not limited to: microcode, device drivers, redundantprocessing units, external disk drive arrays, RAID systems, tape drives,and data archival storage systems, etc.

Computer system 102 may be operational with numerous other generalpurpose or special purpose computing system environments orconfigurations. Examples of well-known computing systems, environments,and/or configurations that may be suitable for use with computer system102 include, but are not limited to, personal computer (PC) systems,server computer systems, thin clients, thick clients, handheld or laptopdevices, multiprocessor systems, microprocessor-based systems, set topboxes, programmable consumer electronics, network PCs, minicomputersystems, mainframe computer systems, and distributed cloud computingenvironments that include any of the above systems or devices, and thelike.

Further details regarding one example of processor 104 are describedwith reference to FIG. 1B. Processor 104 includes a plurality offunctional components used to execute instructions. These functionalcomponents include, for instance, an instruction fetch component 150 tofetch instructions to be executed; an instruction decode unit 152 todecode the fetched instructions and to obtain operands of the decodedinstructions; instruction execution components 154 to execute thedecoded instructions; a memory access component 156 to access memory forinstruction execution, if necessary; and a write back component 160 toprovide the results of the executed instructions. One or more of thesecomponents may, in accordance with an aspect of the present invention,be used to execute one or more register restoration operations and/orinstructions 166, and/or other operations/instructions associatedtherewith.

Processor 104 also includes, in one embodiment, one or more registers168 to be used by one or more of the functional components. Processor104 may include additional, fewer and/or other components than theexamples provided herein.

Further details regarding an execution pipeline of processor 104 aredescribed with reference to FIG. 1C. Although various processing stagesof the pipeline are depicted and described herein, it will be understoodthat additional, fewer and/or other stages may be used without departingfrom the spirit of aspects of the invention.

Referring to FIG. 1C, in one embodiment, an instruction is fetched 170from an instruction queue, and branch prediction 172 and/or decoding 174of the instruction may be performed. The decoded instruction may beadded to a group of instructions 176 to be processed together. Thegrouped instructions are provided to a mapper 178 that determines anydependencies, assigns resources and dispatches the group ofinstructions/operations to the appropriate issue queues. There are oneor more issue queues for the different types of execution units,including, as examples, branch, load/store, floating point, fixed point,vector, etc. During an issue stage 180, an instruction/operation isissued to the appropriate execution unit. Any registers are read 182 toretrieve its sources, and the instruction/operation executes during anexecute stage 184. As indicated, the execution may be for a branch, aload (LD) or a store (ST), a fixed point operation (FX), a floatingpoint operation (FP), or a vector operation (VX), as examples. Anyresults are written to the appropriate register(s) during a write backstage 186. Subsequently, the instruction completes 188. If there is aninterruption or flush 190, processing may return to instruction fetch170.

Further, in accordance with one or more aspects of the presentinvention, coupled to the decode unit is a register renaming unit 192,used in one or more aspects in the saving/restoring of registers.

Additional details regarding a processor are described with reference toFIG. 1D. In one example, a processor, such as processor 104, is apipelined processor that may include prediction hardware, registers,caches, decoders, an instruction sequencing unit, and instructionexecution units, as examples. The prediction hardware includes, forinstance, a local branch history table (BHT) 105 a, a global branchhistory table (BHT) 105 b, and a global selector 105 c. The predictionhardware is accessed through an instruction fetch address register(IFAR) 107, which has the address for the next instruction fetch.

The same address is also provided to an instruction cache 109, which mayfetch a plurality of instructions referred to as a “fetch group”.Associated with instruction cache 109 is a directory 111.

The cache and prediction hardware are accessed at approximately the sametime with the same address. If the prediction hardware has predictioninformation available for an instruction in the fetch group, thatprediction is forwarded to an instruction sequencing unit (ISU) 113,which, in turn, issues instructions to execution units for execution.The prediction may be used to update IFAR 107 in conjunction with branchtarget calculation 115 and branch target prediction hardware (such as alink register prediction stack 117 a and a count register stack 117 b.If no prediction information is available, but one or more instructiondecoders 119 find a branch instruction in the fetch group, a predictionis created for that fetch group. Predicted branches are stored in theprediction hardware, such as in a branch information queue (BIQ) 125,and forwarded to ISU 113.

A branch execution unit (BRU) 121 operates in response to instructionsissued to it by ISU 113. BRU 121 has read access to a condition register(CR) file 123. Branch execution unit 121 further has access toinformation stored by the branch scan logic in branch information queue125 to determine the success of a branch prediction, and is operativelycoupled to instruction fetch address register(s) (IFAR) 107corresponding to the one or more threads supported by themicroprocessor. In accordance with at least one embodiment, BIQ entriesare associated with, and identified by an identifier, e.g., by a branchtag, BTAG. When a branch associated with a BIQ entry is completed, it isso marked. BIQ entries are maintained in a queue, and the oldest queueentry (entries) is (are) de-allocated sequentially when they are markedas containing information associated with a completed branch. BRU 121 isfurther operatively coupled to cause a predictor update when BRU 121discovers a branch misprediction.

When the instruction is executed, BRU 121 detects if the prediction iswrong. If so, the prediction is to be updated. For this purpose, theprocessor also includes predictor update logic 127. Predictor updatelogic 127 is responsive to an update indication from branch executionunit 121 and configured to update array entries in one or more of thelocal BHT 105 a, global BHT 105 b, and global selector 105 c. Thepredictor hardware 105 a, 105 b, and 105 c may have write ports distinctfrom the read ports used by the instruction fetch and predictionoperation, or a single read/write port may be shared. Predictor updatelogic 127 may further be operatively coupled to link stack 117 a andcount register stack 117 b.

Referring now to condition register file (CRF) 123, CRF 123 isread-accessible by BRU 121 and can be written to by the execution units,including but not limited to, a fixed point unit (FXU) 141, a floatingpoint unit (FPU) 143, and a vector multimedia extension unit (VMXU) 145.A condition register logic execution unit (CRL execution) 147 (alsoreferred to as the CRU), and special purpose register (SPR) handlinglogic 149 have read and write access to condition register file (CRF)123. CRU 147 performs logical operations on the condition registersstored in CRF file 123. FXU 141 is able to perform write updates to CRF123.

Processor 104 further includes, a load/store unit 151, and variousmultiplexors 153 and buffers 155, as well as address translation tables157, and other circuitry.

Executing within processor 104 are programs (also referred to asapplications) that use hardware registers to store information. Forinstance, programs that call routines, such as functions, subroutines orother types of routines, are responsible for saving registers used bythe caller and for restoring those registers upon return from thecallee. Likewise, the callee is responsible for saving/restoringregisters that it uses, as shown in the below code.

First, below is example code of a caller that saves a set of registersand later restores them:

Example 1

. . .

# begin call to function printit

STMG 1, 5, 256(15) # Save caller's caller-saved registers

LGFI 1, 1

LGFI 2, 2

LGFI 3, 3

LGFI 4, 4

LGFI 5, 5

BRASL 14, printit # Branch to the function printit

LMG 1, 5, 256(15) # Restore caller-saved registers

In the above caller's code and referring to FIG. 2A, caller-savedregisters are stored, STEP 200. This includes, for instance, a bulk saveof the caller-saved registers using, e.g., a Store Multiple instruction(STMG). Optionally, function parameters are loaded (e.g., using the loadinstruction LGFI), STEP 202, and a function call is performed using, forinstance, a branch instruction (BRASL), STEP 204 (i.e., the callee iscalled). Upon return from the function, the caller-saved registers arerestored, STEP 206. In one example, this is a bulk restore using a LoadMultiple instruction (LMG). (As used herein, a bulk save or bulk storeincludes a store of one or more registers, and a bulk restore or bulkreload includes a load of one or more registers. In one example, thebulk save (store) and the bulk restore (reload) are related tosaving/restoring registers related to function calls. As a particularexample, the bulk save (store) and the bulk restore (reload) are relatedto saving values on a program stack and restoring the values from theprogram stack to the same registers from which they have been stored.)

In one example of a Store Multiple instruction, the contents of bitpositions of the set of general registers starting with general registerR₁ specified by the instruction and ending with general register R₃specified by the instruction are placed in the storage area beginning atthe location designated by the second operand address (e.g., provided bythe contents of the register designated by B₂ plus the contents of D₂;both B₂ and D₂ are specified by the instruction) and continuing throughas many locations as needed. In one example, the contents of bitpositions 32-63 of the general registers are stored in successivefour-byte fields beginning at the second operand address. The generalregisters are stored in the ascending order of their register numbers,starting with general register R₁ and continuing up to and includinggeneral register R₃, with general register 0 following general register15.

In one example of a Load Multiple instruction, bit positions of the setof general registers starting with general register R₁, specified by theinstruction, and ending with general register R₃, specified by theinstruction, are loaded from storage beginning at the locationdesignated by the second operand address (e.g., provided by the contentsof the register designated by B₂ plus the contents of D₂; both B₂ and D₂are specified by the instruction) and continuing through as manylocations as needed. In one example, bit positions 32-63 of the generalregisters are loaded from successive four-byte fields beginning at thesecond operand address and bits 0-31 remain unchanged.

Next, below is example code of a callee that saves a set of registersand later restores them:

Example 1

# Prolog

STMG 11, 15, 88(15) # Save callee's registers

. . .

# function execution

. . .

# Epilog

LG 4, 272(15) # Load return address

LMG 11, 15, 248(15) # Restore registers

BR 4 # Branch back to caller

# Epilog end

In the above callee's code and referring to FIG. 2B, a set ofcallee-saved registers are stored, STEP 220. This occurs, for instance,in the prolog, and includes a bulk save of the callee-saved registersvia, e.g., a Store Multiple instruction (e.g., STMG). Then, processingis performed as part of the function body, including loading the returnaddress back to the caller, STEP 222. Subsequently, the callee-savedregisters are restored, STEP 224. In one example, this occurs in theepilog, and includes a bulk restore of the callee-saved registers via,for instance, a Load Multiple instruction (LMG).

The registers that are saved/restored may be architected or logicalregisters that are mapped to physical registers, as shown in FIG. 3.Referring to FIG. 3, based on, for instance, an instruction referring toan architected register 300, that architected register is associatedwith a physical register 302. In particular, register renaming logic isused to look up a table (or other data structure) to determine whatphysical register corresponds to an architected register. For instance,for read accesses, an architected register is replaced with a physicalregister that is found in the table; and for write accesses, a newphysical register is allocated out of a free list.

The renaming logic may involve, in accordance with one or more aspects,one or more units of the processor. For instance, a processor decodeunit receives instructions; renames target instructions by, e.g.,updating a lookup table associating a set of architected registers tophysical registers obtained from a free list; updates a register renametable for source instructions; takes a rollback snapshot (e.g., copy ofregister rename table) when an instruction or group of instructions maytrigger a rollback (e.g., due to the instruction being able to raise anexception or for a branch instruction that may be mispredicted); andincludes rollback logic adapted to recover a snapshot corresponding toan event requiring a rollback, e.g., for an exception handler or a newbranch target, or cause re-execution.

Further, the renaming logic may involve an execution unit that includesa physical register file accessed by physical register numbers receivedby the decode unit; logic to execute instructions and write results to aspecified physical register; and logic to indicate successful completionor a rollback in the event of, e.g., a branch misprediction orexception.

Additionally, an instruction completion unit is used that receivesreports indicating that instructions have completed; marks snapshots asno longer necessary; adds physical registers to the free list; andupdates an in-order program counter or other in-order state.

While the saving and restoring of caller-saved and callee-savedregisters has been described with respect to examples using generalpurpose registers, other register types, such as floating pointregisters, vector registers, vector-scalar registers, conditionregisters, control registers and/or special purpose registers, as wellas other types of registers may be saved and restored by either a callerfunction, a callee function, or both.

Other, additional and/or fewer units and/or logic may be used.

The saving and restoring of the registers in either or both of thecaller and the callee are costly since they involve using memory.Therefore, in accordance with an aspect of the present invention, acapability is provided to reduce this cost. This capability includes,for instance, using a register snapshot to save and restore theregisters, thereby avoiding, in at least one aspect, the use of memoryin restoring (and optionally, saving) the registers.

In one example, a snapshot is taken of at least a portion of theregister state (e.g., at least a portion of a register rename map, otherregister restoration information, or the full register state) when astore of bulk registers is recognized. Referring to FIG. 4A, a requestfor a bulk store is obtained (e.g., received, determined, provided,retrieved, have, etc.), STEP 400. The bulk store may be, for example, aStore Multiple Instruction that stores multiple registers. The bulk saveis performed, and the contents of the multiple registers are written tomemory, STEP 402. Based thereon, a snapshot is created, STEP 404. (Inanother embodiment, the storing to memory is not performed.)

One example of a snapshot is shown in FIG. 5A. As shown, a snapshot 500a is taken of the mapping of physical registers 502 a to architectedregisters 504. In this example, physical register 45 is assigned toarchitected register 0; physical register 88 is assigned to architectedregister 11; physical register 96 is assigned to architected register12; physical register 67 is assigned to architected register 13;physical register 38 is assigned to architected register 14; andphysical register 22 is assigned to architected register 15. A mappingof these physical registers to the architected registers is captured bysnapshot 500 a.

A physical register file 506 indicates for each physical register 502the value 505 stored within that register.

In one embodiment, a snapshot identifier 508 (e.g., ID 4) is assigned tosnapshot 500 a. Further, in one example, there may also be a pluralityof older snapshots 510 (e.g., snapshots 2 and 3).

As described above, based on recognizing that a bulk save is to beperformed, a snapshot of the registers participating in the bulk save istaken (e.g., snapshot 500 a). Then, processing continues, and as shownin FIG. 5B, new physical registers 502 b are allocated, and the functionis executed.

Thereafter, when the function is complete, the snapshot may berecovered. One example of bulk restore processing is described withreference to FIG. 4B. Initially, in one example, a bulk restore requestis obtained (e.g., received, determined, provided, have, retrieved,etc.), STEP 450. The bulk restore request may be, for example, a LoadMultiple instruction that loads multiple registers. A determination ismade as to whether a corresponding snapshot is available, INQUIRY 452.If a corresponding snapshot is unavailable, then the values are reloadedfrom memory, STEP 454. However, if a corresponding snapshot isavailable, then a further determination is made as to whether the bulkrestore matches the bulk save, INQUIRY 456. That is, are the registersto be restored the same registers that were saved. If they are, then thesnapshot is restored, STEP 458. Additionally, in one example, therestored snapshot is verified, STEP 460. This is pictorially depicted inFIGS. 5C-5D.

As shown in FIG. 5C, the mapping of the physical registers is restoredby recovering 520 the snapshot, resulting in a restored snapshot. Arestored snapshot 530 maps to the same architected registers that werepreviously saved. Thus, referring to FIGS. 5B-5C, p123 assigned to r0 isreplaced with p45; p23 assigned to r11 is replaced with p88; p58assigned to r12 is replaced with p96; p67 assigned to r13 is replacedwith p67 (or no replace is performed); p245 assigned to r14 is replacedwith p38; and p14 assigned to r15 is replaced with p22.

In one example, as depicted in FIG. 5D, only a subset of the registersis recovered. For instance, architected registers 11-15 are recovered,while architected register 0 is not.

As indicated above, in one embodiment of recovering a snapshot, adetermination is made as to whether there is a corresponding snapshot.To determine which snapshot corresponds to a given save/restore pair, anumber of techniques may be used. One technique includes remembering thelast snapshot that was taken. For instance, based on a store multiple, asnapshot is taken, the identifier of that snapshot is remembered, andthe snapshot is marked as available. Then, if another store multiple isperformed, another snapshot is taken, the snapshot id is incremented andthat identifier is remembered, etc. Further, based on a bulk restore,the snapshot id of the last bulk save is recovered and that snapshot ismarked as unavailable.

The tracking of a single snapshot offers a simplified design and enablesrapid snapshot-based register restoration for leaf functions (i.e.,those functions not calling another function). Leaf functions are asizeable fraction of all functions (typically about 50%), which are alsoamong the shortest functions, thus, save and restore processingrepresent a significant fraction of execution time for such functions,which is reduced using the snapshot.

Another technique is to maintain a snapshot stack that can remember anumber of snapshots. As shown in FIG. 6, a snapshot stack 600 includesone or more snapshot identifiers (snapshot ID) 602, one for eachsnapshot taken with the latest snapshot on top, as indicated by atop-of-stack (TOS) pointer 604. In addition to the snapshot ID, in oneor more embodiments, the snapshot stack may optionally includeadditional information. For instance, the values of the registers aresaved to memory (STEP 402) for a number of situations, including, forinstance, in case the snapshot is lost (STEP 454), or if there is a needto confirm if the snapshot contains the latest values (STEP 460). Thus,the additional information may include an address or address range 606of where the value or values of the snapshot registers are stored inmemory.

Additionally, in another embodiment, the snapshot may not be valid forall of the registers contained within the snapshot, but instead only fora subset of the registers. Thus, in one example, the snapshot stack mayinclude for each snapshot, a register from indication 608 and a registerto indication 610 that provide the registers that are valid for thesnapshot.

Further, a valid indicator 612 may optionally be provided to indicatewhether the snapshot is valid. Other, additional and/or less informationmay be provided in other embodiments.

To manage the snapshot stack, the top-of-stack pointer is adjusted. Forinstance, based on creating a snapshot, a new entry is added to thestack, and the top-of-stack pointer is incremented. Further, whenrestoring a snapshot, the entry corresponding to the top-of-stackpointer is removed from the stack, and the top-of-stack pointer isdecremented. If, for instance, there is a branch misprediction or anexception, then multiple entries may be removed and the top-of-stackpointer is appropriately adjusted.

Other techniques for determining corresponding Store Multiple/LoadMultiple pairs may be used.

In one aspect, the save and restore of the registers are based onperforming Store Multiple or Load Multiple instructions (or similarinstructions). However, these instructions may be used for manypurposes, and therefore, checking and/or heuristics may be used toensure correct execution is preserved. That is, a determination is madeof the store/load pairs, which then may be optimized using the savingand restoring aspects of the present invention. Unmatching store/loadpairs are not optimized using the saving/restoring aspects of thepresent invention. Thus, to facilitate processing and to reduce thechecking or heuristics associated with, e.g., finding the matching pairsto ensure correct execution, new instructions are defined that behavedifferently than the load multiple/store multiple instructions. Forinstance, the new instructions, referred to herein as Spill Multiple(Spillm) and Reload multiple (Reloadm) are defined such that they do notconsider modifications to memory that occur between the spill andreload. That is, in accordance with one architectural definition ofthose instructions, the user of Spillm/Reloadm is not to modify thein-memory values corresponding to those registers between the spill andthe reload. Thus, if an in-memory image is modified, the newinstructions are not obligated to consider that value.

One example of a Spill Multiple instruction is described with referenceto FIG. 7A. In one example, a Spill Multiple (Spillm) instruction 700includes at least one operation code field 702 that includes anoperation code (opcode) indicating a spill multiple operation; a firstregister (R₁) field 704; a second register (R₃) field 706; a base field(B₂) 708; and a displacement field (D₂) 710 (e.g., a 12-bit unsignedbinary integer). In another embodiment, the displacement field mayinclude multiple fields (e.g., DL₂ and DH₂) and may be, e.g., a 20-bitunsigned binary integer (other sizes are also possible). Each of thefields is separate from one another, in one example. However, in otherexamples, one or more of the fields may be combined. Further, in oneexample, the subscript number associated with a field designates theoperand to which that field corresponds. For instance, a field having asubscript number 1 corresponds to a first operand; a field having asubscript number 2 corresponds to a second operand; and so on.

In operation, the contents of bit positions of the set of generalregisters starting with general register R₁ and ending with generalregister R₃ are preserved for later restoration. The storage areabeginning at the location designated by the second operand address(e.g., provided by the contents of the register designated by B₂ plusthe contents of D₂ or DL₂ plus DH₂) and continuing through as manylocations as needed may be used as a buffer to store some or all of theregisters. The corresponding buffer storage address is to be specifiedfor a corresponding recovery address. In one example, the contents ofbit positions 32-63 of the general registers are stored in successivefour-byte fields beginning at the second operand address. The generalregisters are preserved for later restoration. In another format ofSpillm, the contents of bit positions 0-63 of the general registers arepreserved for later restoration. A buffer corresponding to 4 bytes (orin the other embodiment, 8 bytes) per register may be used and are to beaccessible. The content of the buffer is undefined and may change fromsystem generation to system generation. In another embodiment, thebuffer is defined and contains a value corresponding to the value of thestorage area in accordance with the definition of a corresponding StoreMultiple instruction.

Further, in operation, in accordance with one aspect, a snapshot of theone or more registers indicated by the instruction is taken to have amapping of the physical registers to the specified architectedregisters.

One example of a Reload Multiple instruction is described with referenceto FIG. 7B. In one example, a Reload Multiple (Reloadm) instruction 750includes at least one operation code field 752 that includes anoperation code (opcode) indicating a reload multiple operation; a firstregister (R₁) field 754; a second register (R₃) field 756; a base field(B₂) 758; and a displacement field (D₂) 760 (e.g., a 12-bit unsignedbinary integer). In another embodiment, the displacement field mayinclude multiple fields (e.g., DL₂ and DH₂) and may be, e.g., a 20-bitunsigned binary integer (other sizes are possible). Each of the fieldsis separate from one another, in one example. However, in otherexamples, one or more of the fields may be combined. Further, in oneexample, the subscript number associated with the field designates theoperand to which that field corresponds. For instance, a field having asubscript number 1 corresponds to a first operand; a field having asubscript number 2 corresponds to a second operand; and so on.

In operation, in accordance with an aspect of the present invention, bitpositions of the set of general registers starting with general registerR₁ and ending with general register R₃ are restored from the most recentsnapshot, removing the most recent snapshot and making its precedingsnapshot available as most recent snapshot for subsequent ReloadMultiple instructions. In one example, bit positions 32-63 of thegeneral registers are reloaded from a previously stored value, and bits0-31 remain unchanged. In another embodiment, bit positions 0-63 of thegeneral registers are restored from a previously stored value. Thegeneral registers are loaded in the ascending order of their registernumbers, starting with general register R₁ and continuing up to andincluding general register R₃, with general register 0 following generalregister 15.

If a snapshot is unavailable, then the registers are loaded from storagebeginning at the location designated by the second operand address(e.g., provided by the contents of the register designated by B₂ plusthe contents of D₂ (or DL₂ plus DH₂).

The result of this operation can be undefined for a variety of reasons,including: a preceding Spill Multiple instruction did not specify thesame register range to be prepared for restore. (In another embodiment,the result is undefined when a previous Spill Multiple instruction didnot specify a superset of the register range to be prepared forrestore); the Reload Multiple Instruction does not specify the samebuffer (In one embodiment, this is to be the same address. In anotherembodiment, this is to be an adjusted address when a subset of registersare restored); or the buffer has been modified by interveninginstructions.

With the use of Reloadm, in one embodiment, the snapshot is not verified(as in FIG. 4B), since in accordance with the architectural definitionof Reloadm, the user is not to modify the stored data corresponding tothose registers. Thus, as shown in FIG. 8A, there is no verify snapshotafter the restore snapshot.

For instance, as described with reference to FIG. 8A, a bulk restorerequest (e.g., a Reloadm instruction) is obtained (e.g., received,determined, provided, have, retrieved, etc.), STEP 800. A determinationis made as to whether a corresponding snapshot is available, INQUIRY802. This determination may be made using the techniques describedabove, such as remembering the last snapshot id, using a snapshot stack,and/or other techniques.

If a corresponding snapshot is unavailable, then the values are reloadedfrom memory, using for instance, a Load Multiple or similar instruction,STEP 804. However, if a corresponding snapshot is available, then afurther determination is made as to whether the bulk restore matches thebulk save (e.g., performed by Spillm), INQUIRY 806. That is, are theregisters to be restored the same registers that were saved. If theyare, then the snapshot is restored, STEP 808. For instance, the mappingof the physical registers to the architected registers is changed toreflect the last snapshot. Since Reloadm was used in the restoration,the snapshot is not verified, as is when a Load Multiple is used.

Further, in one example, since a Reloadm instruction is architecturallyguaranteed to match a previous Spillm instruction, the matchverification may also be suppressed, as shown in FIG. 8B. Morespecifically, it is the programmer's responsibility to matchcorresponding pairs of Spillm and Reloadm, at the penalty of anundefined result when such a match is not guaranteed by the programmer.In this embodiment, a bulk restore request (e.g., Reloadm) is obtained(e.g., received, determined, provided, have, retrieved, etc.), STEP 820,and a determination is made as to whether a corresponding snapshot isavailable, INQUIRY 822. If a corresponding snapshot is unavailable, thenthe values are reloaded from memory (e.g., using Load Multiple), STEP824. Otherwise, the snapshot is restored, STEP 826 (an inquirycorresponding to INQUIRY 806 is not performed).

In one embodiment, support for bulk saves/restores in accordance withconventional store multiple and load multiple bulk requests (e.g., usingthe STMG and LMG instructions in accordance with the z/Architecture, orusing the STM and LM—or STMW and LMW and STMD and LMD instructions,respectively, in the Power ISA, in example embodiments) may be combinedwith the new Spillm/Reloadm facility in at least one embodiment. Inaccordance with such an embodiment, code in accordance with conventionalISA (instruction set architecture) definitions may be accelerated, butuse additional checking to ensure adherence to the architecturalcompliance with the conventional instruction definition, whereasproviding even higher performance due to reduced checking for the codeusing the new Spillm/Reloadm instructions in accordance with aspects ofthe present invention.

In accordance with another aspect of the present invention, snapshotsmay be shared between adjacent register restoration points. Thesesnapshots are taken of at least a portion of a register rename map, ofother register restoration information, or of the full register state,as examples.

A function call is often associated with two sets of matched registerspill and register reload pairs (e.g., STMG and LMG, or Spillm andReloadm)—one associated with the saving of caller-saved registers at thecall site, and another one associated with the saving of callee-savedregisters in the called function. The spills (i.e., the saving ofmultiple architected registers) usually execute in close dynamicproximity, and similarly, the restores or reloads of the registers areusually dynamically close, as well. Further, the registers are mutuallyexclusive, and the registers to be saved by the second spill operationare commonly not modified by code between the first and second spill.Example code, in pseudocode notation, is below:

caller_function( ) {  various computation  spillm r10-r15, offset1(sp)// Spillm is one example  jsr called_function  reloadm r10-r15,offset1(sp) // Reload is one example  various computation }called_function( ) { sub sp, sp, framesize // allocate framesize  spillmr16-r20, offset2(sp)  various computation  reloadm r16-r20, offest2(sp) ret }

Based on the foregoing, in accordance with an aspect of the presentinvention, at least part of a register restoration snapshot may beshared between dynamically adjacent instances of spill operations (e.g.,Spillm instructions). In one example, a processor may create arestoration snapshot that includes a single snapshot of the registerstate used for restoring both r10-r15 of the caller function and r16-r20of the callee function. It should be noted that the ranges of savedregisters do not have to be adjacent.

To accomplish this, in one embodiment, a restoration snapshot includestwo separate records: an address to which a spill has occurred and aregister snapshot to be used in restoration. The register snapshot isshared, but separate address values are maintained for eachSpillm/Reloadm pair: <address, snapshot-ID>.

The processor maintains, in accordance with an aspect of the presentinvention, a reference to the last restoration snapshot taken (whichincludes registers that may be referenced by a plurality of spilloperations), in conjunction with a bitmap of register values that havenot been written to since the last restoration snapshot. Thus, when anew restoration snapshot is to be taken, if the register range to besnapshot has not been modified since the last restoration snapshot, thepresent spill operation can reuse the previous restoration snapshot.Otherwise, a new restoration snapshot may be created.

One example of instruction decode and snapshot logic for sharingsnapshots is provided below:

last_snapshot = null; unmodifiedregs = { }; Repeat Indefinitely {  ni =obtain instruction  if ni is a spill instruction {   if spill_range(ni)not in unmodifiedregs {    last_snapshot = take_snapshot( )   unmodifiedregs = {r0...rmax}; // all registers are unmodified   }  rr = create_restoration_record (spill_to_address, last_snapshot);  push_restoration_record(rr);   emit spill iops( );  } else if ni is areload instruction {   rr = pop_restoration_record( );   emit reloadiops(rr);  } else {   unmodifiedregs := unmodifiedregs and not(target(ni));   handle other instructions  } }

As shown in FIG. 9, since would-be snapshot 4 is the same as snapshot 3,in one embodiment, snapshot 4 is not taken and snapshot 3 is reused.This is shown by a dotted line around snapshot 4 and an indication ofthe last snapshot taken, bulk save snapshot 900, being set to 3.

Further details regarding managing restoration snapshots, in accordancewith one or more aspects of the present invention, are described withreference to FIGS. 10A-10E. In FIGS. 10A-10E, snapshot refers to arestoration snapshot; i.e., a snapshot taken based on execution of oneor more bulk saves (e.g., Spillm and/or Store Multiple). Initially, oneembodiment of sharing a restoration snapshot is described with referenceto FIG. 10A. In this embodiment, snapshot_regs is set to those registersthat are to be included in a restoration snapshot, STEP 1000. Forinstance, a determination is made of the registers to be included, suchas those to be included in one or more Spillm or Store Multipleinstructions, and an indication of those registers is provided insnapshot_regs.

A check is made as to whether a previous snapshot is usable, STEP 1002.This includes determining whether the registers specified for thepresent snapshot include only unmodified registers from the previoussnapshot since that snapshot was taken. Unmodified_regs is used to trackwhich registers have not been modified since the last snapshot. In oneexample, prev_snapshot_usable is set to an indication of whether theintersection of the snapshot registers for the present snapshot and theunmodified registers, i.e., (snapshot_regs & unmodified_regs), containsall registers for the present snapshot, i.e., is the same as (i.e., ==)snapshot_regs. If there are no modified registers included insnapshot_regs, then the previous snapshot is usable. If the previoussnapshot is usable, INQUIRY 1004, then this_snapshot_ID is set equal tothe identifier of the previous snapshot identifier, prev_snapshot_ID,STEP 1006.

If, however, the previous snapshot is not usable, INQUIRY 1004, thenanother snapshot is taken, and this_snapshot_ID is updated (e.g.,incremented by 1), STEP 1010. Further, unmodified_regs is set to includeall of the registers, since it is initialized with no registers havingbeen modified, STEP 1012. Additionally, prev_snapshot_ID is set equal tothis_snapshot_ID, such that this snapshot is remembered for further use,STEP 1014.

In a further embodiment, referring to FIG. 10B, the registers that aremodified by an instruction are tracked. In one example, a determinationis made as to whether an instruction changes the contents of one or moreregisters, INQUIRY 1020. If one or more registers are modified by theinstruction, then those registers are tracked, STEP 1022. For instance,unmodified_regs is set to exclude those one or more registers that weremodified (e.g., unmodified_regs:=unmodified_regs AND NOT regs_changed_byinstruction). Subsequent to updating unmodified_regs or if theinstruction has not changed any registers, INQUIRY 1020, this processingis complete, STEP 1024.

In addition to the above, in a further embodiment, if the instructionpipeline rewinds to a previous point due to an event (e.g., flush,branch misprediction, exception, etc.), then a new snapshot is forced.One example of processing associated with forcing a snapshot due to aflush/branch misprediction/exception is described with reference to FIG.10C. In this example, prev_snapshot_id is set to NONE indicating thereis no previous snapshot that may be shared, STEP 1030, andunmodified_regs is set to no_regs, STEP 1032. That is, there is noindication of a usable previous snapshot, and there are no registersconsidered unmodified.

Further, in one example, if the instruction rewinds to a previous pointdue to an event (e.g., flush, branch misprediction, exception, etc.),rollback to a previous snapshot may be performed, as described withreference to FIG. 10D. Initially, a determination is made as to whetherprocessing should roll back to a snapshot, INQUIRY 1040. That is, has anevent occurred that suggests rollback and is there an appropriatesnapshot to which to roll back. If there is to be a rollback to asnapshot, then prev_snapshot_ID is set equal to rollback_snapshot_ID,which is the snapshot to which processing is rolled back, STEP 1042.Additionally, unmodified_regs is set to all of the registers, since atthis point, no registers have been modified, STEP 1044.

Returning to INQUIRY 1040, if there is no rollback to a snapshot, thenprev_snapshot_ID is set to NONE, STEP 1046, and unmodified registers isset to no registers, STEP 1048.

A further example of processing associated with rolling back to asnapshot due to an event, such as a flush, branch misprediction,exception, is described with reference to FIG. 10E. Initially, adetermination is made as to whether processing is to roll back to orbeyond the last snapshot, INQUIRY 1050. If not, this processing iscomplete and the last snapshot may be used, STEP 1052. In oneembodiment, with processing of rolled back instructions, the set ofunmodified registers may contain a subset of the truly unmodifiedregisters, as processing of rolled back instructions in accordance withthe technique of FIG. 10B may have removed registers from the unmodifiedregister set. However, this is a conservative definition of the subset,i.e., in the worst case there may be more snapshots taken thannecessary, thereby preserving correctness. At the same time, the set ofsnapshots that may be taken is fewer than those in accordance with FIG.10C or FIG. 10D, in which each snapshot request triggers a snapshotbeing taken in accordance with the technique of FIG. 10C, and inaccordance with choosing STEPS 1046 and 1048 of FIG. 10D.

Otherwise, a determination is made as to whether processing is to rollback to a snapshot, INQUIRY 1054. If there is to be a rollback to asnapshot, then prev_snapshot_ID is set equal to rollback_snapshot_ID,which is the snapshot to which processing is rolled back, STEP 1056.Additionally, unmodified_regs is set to all of the registers, since atthis point, no registers have been modified, STEP 1058.

Returning to INQUIRY 1054, if there is no rollback to a snapshot, thenprev_snapshot_ID is set to NONE, STEP 1060, and unmodified registers isset to no registers, STEP 1062.

Although various embodiments are provided above, other embodiments maybe used to manage which snapshot to be used in particular circumstances.

In a further aspect of the invention, in addition to using sharedsnapshots for restoration, shared snapshots may be used in recovery. Asused herein, snapshots for restoration are those snapshots taken basedon a bulk save (e.g., Store Multiple, Spillm, etc.); and snapshots forrecovery are those snapshots taken based on a change to execution flow,such as a branch or a situation where an address may be mispredicted, asexamples.

Consider the following example function: caller_function( ) {  variouscomputation  bcond <cond> skip: // snapshot for branch misprediction/exceptions  spillm r10-r15, offset1(sp) // snapshot for spill multiple jsr called_function // snapshot-address may be mispredicted  reloadmr10-r15, offset1(sp)  various computation skip: }

In the above example, recovery snapshots are taken for the branchconditional (bcond) instruction and the jump (jsr) instruction, andrestoration snapshots are taken for the Spillm instruction. In thisexample, the recovery snapshots (e.g., for the branch conditional andthe jump) may be shared, similar to the sharing of the snapshots forrestoration (e.g., multiple spill operations). This is described furtherwith reference to FIG. 10F.

One example of sharing a recovery snapshot is described with referenceto FIG. 10F. In one example, the processing of FIG. 10F is performedwhen a recovery snapshot is to be made, e.g., to create a rollback pointfor branch misprediction recovery implementing precise exceptions,handling pipeline flushes, or other such events. Initially, the set ofregisters to be snapshot for a recovery snapshot, snapshot_regs, is setequal to all of the registers (all_regs( )), e.g., all of the registersto be saved for recovery in the event of a precise exception, branchmisprediction, or other such event (e.g., the registers associated withthe conditional branch bcond and subroutine call jsr, in this example),STEP 1070. A check is made as to whether a previous snapshot is usable,STEP 1072. This includes determining whether the registers to be usedfor the present snapshot (which corresponds to all registers, inaccordance with STEP 1070, in one example) includes only unmodifiedregisters since the previous snapshot was taken. In one example, theindicator, prev_snapshot_usable, is set equal to an indication ofwhether unmodified_regs==all_regs. If there are no modified registers insnapshot_regs, then the previous snapshot is usable. If the previoussnapshot is usable, INQUIRY 1074, then this_snapshot_ID is set equal toprev_snapshot_ID, STEP 1076, (i.e., the previous snapshot is usable forproviding a snapshot for the present snapshot request). Otherwise, if aprevious snapshot is not usable, then a snapshot is made, andthis_snapshot_ID is updated (e.g., incremented by one), STEP 1078.Further, unmodified_regs is set equal to all registers, STEP 1080, andprev_snapshot_ID is set equal to this_snapshot_ID, STEP 1082, such thatthe present snapshot may be reused for future snapshot requests, e.g.,at least with one or more of a recovery and a restoration snapshotrequest in accordance with embodiments of aspects of the presentinvention.

In one embodiment, the processing of FIG. 10F implemented for sharingrecovery snapshots may operate in conjunction with the processing of oneor more of FIGS. 10A-10E implemented for sharing restoration snapshots.In one aspect, snapshots may be shared for recovery, for restoration orfor a combination of recovery and restoration. The technique of FIG.10F, as one example, can be used for sharing snapshots, regardless ofthe type.

While FIGS. 10A-10F have been described with respect to a singlesnapshot for a register file, in accordance with embodiments of aspectsof the present invention, the register snapshot techniques describedherein may be performed for a variety of register types, including butnot limited to general registers, integer registers, address registers,data registers, fixed point registers, floating point registers, vectorregisters, vector-scalar registers, condition registers, predicateregister, control registers, special purpose registers, etc. Inaccordance with one embodiment, multiple register types may be supportedin a single implementation, so as to provide, for example, snapshots forgeneral purpose and vector registers (or other combinations of registertypes). Further, a plurality of register types may share a snapshotmechanism, in accordance with one or more embodiments. In one exampleembodiment, snapshots for floating point and vector registers may beshared, e.g., with an implementation in accordance with thez/Architecture providing for shared vector and floating point registers.In another example embodiment, snapshots for floating point, vectorregisters and vector-scalar registers may be shared, e.g., with animplementation in accordance with the Power ISA providing for sharedvector-scalar, vector, and floating point registers. Other examples arealso possible.

In a further aspect of the present invention, changes to memory aretracked in order to determine, if desired, whether restored registersare correct (i.e., does the snapshot used to recover the registers havethe most current information). For instance, in one embodiment in whichStore Multiple and Load Multiple instructions (or other suchinstructions) are used, changes to memory that occur between the loadand store are captured to be able to determine correctness, if desired,of the restored registers in accordance with the values previouslystored by a store multiple request and to be reloaded by a load multipleinstruction, when the registers are restored from a register restorationsnapshot rather than from memory. (Using Spillm/Reloadm provides abenefit here in which the correctness of a register restoration snapshotwith respect to an in-memory buffer is not a concern of this processing,since by architectural definition, memory changes are not to be made bya programmer and represent a programming error resulting in undefinedbehavior. Thus, if memory changes are made between Spillm and Reloadm toa memory buffer used by these instructions, by architectural definition,such a change is considered a programming error, and the programmer isresponsible for handling such an error, not this processing associatedwith the Spillm/Reloadm instructions.)

One example of code including save and restore operations is depictedbelow:

called function( ) {  sub sp, sp framesize // allocate framesize  STMr16-r20, offset2(sp) // Store Multiple; create snapshot  variouscomputation  LM r16-r20, offset2(sp) // Load Multiple; restore snapshot ret }

The restore recovers the value of the callee-saved registers at thepoint where the function was entered and the callee-saved registers weresaved. However, instructions between STM and LM may change memory whichaffects the callee-saved registers when restored. This is demonstratedin the example below:

Example 1

called function( ) {  sub sp, sp, framesize    // allocate framesize; spis stack pointer  STM r16-r20, offset2(sp)   // save registers 16-20 tomemory at offset from sp  ...various computation...  L1 r1, 99  // load99 into register 1  ST r1, offset2(sp)  // store value of register 1 tomemory at offset from sp  LM r16-r20, offset2(sp) // restore registers16-20 from memory -- value 99       // stored // at offset from stackpointer being loaded into r16;  ret }

Restoring the registers, based on receiving the Load Multiple, from asnapshot, instead of loading the registers from memory would restore thevalue originally in the register at the snapshot point corresponding tothe values at the STM instruction, not the modified value 99 stored intothe in-memory register restoration buffer location corresponding toregister r16. Therefore, one or more aspects are provided to determinewhether the memory has changed compromising the integrity of thesnapshot.

In accordance with aspects of the present invention, various embodimentsare provided to address possible memory changes between save and restoreoperations, including for instance: (1) restoring, checking andrecovering, if necessary; (2) using Spillm/Reloadm, wherein bydefinition, the memory is not modified in-between the save and restore;and (3) tracking any changes without explicit checking. Each of theseaspects is described further below.

As indicated above, one embodiment to address the scenario in which aregister value is changed in memory between a store and a load is to usea restore, check and recover technique in accordance with an aspect ofthe present invention. In accordance with this aspect, a registersnapshot is restored based on receiving a register restoration request.Further, based on the request and restoring registers from a snapshot,each of the registers restored from a register snapshot is checked byloading the corresponding register value from the memory buffercorresponding to the register save/restore pair, and comparing the valuerestored from the register snapshot to the value loaded from the memorybuffer. If a mismatch is detected, the restored registers are recoveredfrom the in-memory buffer. Otherwise, the restored registers from thesnapshot are used. Advantageously, the checking of the registers can beperformed in parallel to performing computation using the restoredvalues, thereby enabling the application program to proceed withcomputation even if the checking has not completed.

As described herein, in one example, if a check fails, then all of theregisters are recovered using the memory values. This is describedfurther with reference to FIG. 11A.

Initially, a restore operation is obtained (e.g., received, provided,determined, retrieved, have, etc.), STEP 1100. For instance, a LoadMultiple instruction is received. A determination is made as to whetherthe restore operation matches the previous save operation (e.g., do theregisters of the Load Multiple match the registers of the Store Multiplepaired with the Load Multiple; are the addresses the same; is a subsetof the registers or addresses the same; etc.), INQUIRY 1102. If theregisters to be restored correspond to those that were saved, then thelast snapshot is obtained and used to restore the registers, STEP 1104.

Subsequent checking is performed to determine correctness of therestored values. Serialization for the subsequent checking is providedto ensure that checking commences after a snapshot has been restored,STEP 1106, and an indicator indicating whether a mismatch in whichrecovery of values from memory is to be performed, referred to asmismatch, is initialized to FALSE, STEP 1108. A stored valuecorresponding to a selected register is loaded from memory using, e.g.,a micro-operation, STEP 1110. That loaded value is compared to therestored value of the selected register being checked, STEP 1112. If thecompare fails, i.e., the loaded value does not match the restored value,mismatch is set to TRUE. The processor checks the mismatch indicator andif it indicates a failed compare, INQUIRY 1114, then the pipeline isflushed and a restart is performed after the restore operation, STEP1116. Additionally, the values for the registers being restored arereloaded from memory, STEP 1118.

In one example, the flush is performed in order to cause allinstructions that may have executed speculatively using the values fromthe restored snapshot to be re-executed with the values obtained frommemory when a mismatch was detected. In at least one embodiment, theflush can be more selective, causing, e.g., only a flush andre-execution of instructions depending on the restored registers.

Returning to INQUIRY 1114, if, however, mismatch indicates a successfulcompare, then a determination is made as to whether there are morerestored registers to be checked, INQUIRY 1120. If there are morerestored registers to be checked, then processing continues to STEP1110. Otherwise, processing is complete.

Returning to INQUIRY 1102, if the restore request does not match thestore request, then the values of the registers are reloaded frommemory, STEP 1118.

In one embodiment, one or more steps of FIG. 11A are implemented byexpanding a restore operation into one or more multiple internaloperations (iops) corresponding to one or more of the steps of FIG. 11Athat may be executed out-of-order with respect to other instructionsand/or internal operations corresponding to other instructions. Inanother aspect of the present invention, iops generated corresponding tothe present instruction may be executed out-of-order relative to eachother. In accordance with this implementation, out-of-order executionlogic provides suitable interlocks so as to ensure that subsequentoperations are only executed when a snapshot has been restored, andfurther any speculative executed instructions that have been executedbased on a restored value are invalidated, flushed and re-executed whena mismatch is detected.

In another embodiment, the steps of FIG. 11A are implemented as steps ofdedicated circuitry for register restoration and validation. In at leastone embodiment, the logic corresponding to FIG. 11A is performed inparallel to executing subsequent instructions using restored valueswhile the circuitry implementing the technique herein continues toverify the restored registers. Furthermore, there is provided suitableinterlocks so as to ensure that subsequent operations are only executedwhen a snapshot has been restored, and further any speculativelyexecuted instructions that have been executed based on a restored valueare invalidated, flushed and re-executed when a mismatch is detected.

Another embodiment of the restore, check and recover technique isdescribed with reference to FIG. 11B. In this embodiment, it is possiblethat one or more registers are restored from a snapshot, but one or moreother registers are restored from memory. Referring to FIG. 11B, arestore operation, such as a Load Multiple, is obtained (e.g., received,provided, retrieved, determined, have, etc.), STEP 1130. A determinationis made as to whether the restore operation matches the previous saveoperation (e.g., do the registers of the Load Multiple match theregisters of the Store Multiple paired to the Load Multiple; are theaddresses the same; is a subset of the registers or addresses the same;etc.), INQUIRY 1132. If the registers to be restored correspond to thosethat were saved, then the last snapshot is obtained and used to restorethe registers, STEP 1136.

Thereafter, subsequent checking is performed to determine correctness ofthe restored values. Serialization for the subsequent checking isprovided to ensure that checking commences after a snapshot has beenrestored, STEP 1138, and first_mismatch is set to NONE, STEP 1140. Astored value corresponding to a selected register is loaded from memoryusing, e.g., a micro-operation, STEP 1142. That loaded value is comparedto the restored value of the selected register being checked, STEP 1144.If the compare fails, i.e., the loaded value does not match the restoredvalue, first_mismatch is set to the register that failed the compare. Iffirst_mismatch is no longer equal to NONE, the processor determinesthere is a mismatch. INQUIRY 1146, and the pipeline is flushed and arestart is performed after the restore operation, STEP 1150.Additionally, the values in the register of the failed compare andsubsequent registers are reloaded from memory, STEP 1152.

In one example, the flush is performed in order to cause allinstructions that may have executed speculatively using the values fromthe restored snapshot to be re-executed with the values obtained frommemory when a mismatch was detected. In at least one embodiment, theflush can be more selective, causing, e.g., only a flush andre-execution of instructions depending on the restored registers, ordepending on the restored registers that are recovered from memory,starting with the first_mismatch register.

Returning to INQUIRY 1146, if, however, the compare is successful, thena determination is made as to whether there are more restored registersto be checked, INQUIRY 1148. If there are more restored registers to bechecked, then processing continues to STEP 1142. Otherwise, processingis complete.

Returning to INQUIRY 1132, if the restore request does not match thestore request, then the values of the registers are reloaded frommemory, STEP 1134.

In one embodiment, one or more steps of FIG. 11B are implemented byexpanding a restore operation into one or more multiple internaloperations (iops) corresponding to one or more of the steps of FIG. 11Bthat may be executed out-of-order with respect to other instructionsand/or internal operations corresponding to other instructions. Inanother aspect of the present invention, iops generated corresponding tothe present instruction may be executed out-of-order relative to eachother. In accordance with this implementation, out-of-order executionlogic provides suitable interlocks so as to ensure that subsequentoperations are only executed when a snapshot has been restored, andfurther any speculative executed instructions that have been executedbased on a restored value are invalidated, flushed and re-executed whena mismatch is detected.

In another embodiment, the steps of FIG. 11B are implemented as steps ofdedicated circuitry for register restoration and validation. In at leastone embodiment, the logic corresponding to FIG. 11B is performed inparallel to executing subsequent instructions using restored valueswhile the circuitry implementing the technique herein continues toverify the restored registers. Furthermore, there is provided suitableinterlocks so as to ensure that subsequent operations are only executedwhen a snapshot has been restored, and further any speculativelyexecuted instructions that have been executed based on a restored valueare invalidated, flushed and re-executed when a mismatch is detected.

Another embodiment of restoring, checking and recovering is describedwith reference to FIG. 11C. In this example, individual registers aretracked and may be restored using the snapshot, while others may berestored from memory.

Referring to FIG. 11C, initially, a restore operation (e.g., a LoadMultiple) is obtained (e.g., received, provided, determined, retrieved,have, etc.), STEP 1160. A determination is made as to whether therestore operation matches the previous save operation (e.g., do theregisters of the Load Multiple match the registers of the Store Multiplepaired to the Load Multiple; are the addresses the same; is a subset ofthe registers or addresses the same; etc.), INQUIRY 1162. If theregisters to be restored correspond to those that were saved, then thelast snapshot is obtained and used to restore the registers, STEP 1166.Thereafter, subsequent checking is performed to determine correctness ofthe restored values. Serialization for the subsequent checking isprovided to ensure that checking commences after a snapshot has beenrestored, STEP 1168, and a mismatch set is set to an empty set, STEP1170.

A stored value corresponding to a selected register is loaded frommemory using, e.g., a micro-operation, STEP 1172. That loaded value iscompared to a restored value of the selected register being checked,STEP 1174. If the compare fails, i.e., loaded value does not match therestored value, INQUIRY 1176, then the miscompared register is added tothe mismatch set, STEP 1178.

Thereafter, or if the compare is successful, INQUIRY 1176, then adetermination is made as to whether there are more restored registers tobe checked, INQUIRY 1180. If there are more restored registers to bechecked, then processing continues to STEP 1172. Otherwise, adetermination is made as to whether the mismatch set is empty, INQUIRY1182. If the mismatch set is empty, processing is complete. Otherwise,the registers in the mismatch set are reloaded with the values frommemory, STEP 1184.

In one example, reload in accordance with STEP 1184 may causere-execution of some or all of the instructions either following therestore instruction, or depending on one of the restored values. In oneembodiment, this is achieved by causing a full or partial flush in orderto cause all instructions that may have executed speculatively using thevalues from the restored snapshot to be re-executed with the valuesobtained from memory when a mismatch was detected. In at least oneembodiment, the flush is selective, causing, e.g., only a flush andre-execution of instructions depending on the restored registers of theinstruction, or depending on the restored registers that are recoveredfrom memory, as represented by the registers in the mismatch set.

Returning to INQUIRY 1162, if the restore request does not match thestore request, then the values of the registers are reloaded frommemory, STEP 1164.

In one embodiment, one or more steps of FIG. 11C are implemented byexpanding a restore operation into one or more multiple internaloperations (iops) corresponding to one or more of the steps of FIG. 11Cthat may be executed out-of-order with respect to other instructionsand/or internal operations corresponding to other instructions. Inanother aspect of the present invention, iops generated corresponding tothe present instruction may be executed out-of-order relative to eachother. In accordance with this implementation, out-of-order executionlogic provides suitable interlocks so as to ensure that subsequentoperations are only executed when a snapshot has been restored, andfurther any speculative executed instructions that have been executedbased on a restored value are invalidated, flushed and re-executed whena mismatch is detected.

In another embodiment, the steps of FIG. 11C are implemented as steps ofdedicated circuitry for register restoration and validation. In at leastone embodiment, the logic corresponding to FIG. 11C is performed inparallel to executing subsequent instructions using restored valueswhile the circuitry implementing the technique herein continues toverify the restored registers. Furthermore, there is provided suitableinterlocks so as to ensure that subsequent operations are only executedwhen a snapshot has been restored, and further any speculativelyexecuted instructions that have been executed based on a restored valueare invalidated, flushed and re-executed when a mismatch is detected.

Although various techniques are described above, variations to thosetechniques may be made without departing from the spirit of aspects ofthe invention.

In accordance with another aspect, the checking for memory changes isnot performed, since the saving and restoring are performed using Spillmand Reloadm instructions (or similar instructions), which arearchitecturally defined to not allow, between the spillm and reloadm,memory changes to the register values stored in memory. In thisapproach, the instruction definition indicates that the restoredregister values are undefined if the memory is modified. In accordancewith the definition of the instructions, the user is not to modify thecorresponding stored area. If the user does modify the area, this isconsidered a programming error and correctness is not guaranteed.

Example definitions of the Spillm and Reloadm instructions are describedabove. However, further details are provided herein. In one embodiment,Spillm saves the register values to memory so that they can be used as,for instance, a fallback in case of snapshot invalidation. Snapshotinvalidation may occur, for example, if the processor runs out ofphysical registers, the processor runs out of storage for snapshots,there is a context switch, etc.

In one embodiment, when using Spillm and Reloadm, it is architecturallydefined that the verify snapshot of FIG. 4B is not needed. Therefore, asshown in FIG. 8A, there is no snapshot verification performed.Similarly, in accordance with another aspect, the bulk restore may beperformed without using the matching inquiry (e.g., INQUIRY 806), sinceit may be architecturally defined that the Reloadm is to match theSpillm. One example of this is described above with reference to FIG.8B, in which no matching inquiry is performed.

Although the architectural definitions of Spillm/Reloadm allow theskipping of the matching inquiry, there may be situations in whichSpillm and Reloadm become unmatched. For instance, the pairs may becomeunmatched based on setjump/longjump functions in a program in accordancewith the C/C++ and POSIX definitions of the setjump and longjumpfunctions and/or responsive to structured exception handling, e.g., suchas used in accordance with exception handling as represented in C++ andJava, as examples. One example of exception handling and resultingunmatched Spillm/Reloadm instructions is shown below:

Caller( ) {  Spillm  try {   callee( ) // See Callee( ) below  } catch(Exception e)... // Stack unwind is performed; // Reloadm in callee notexecuted, so  Reloadm // This Reloadm is matched with callee's Spillm }Callee( ) {  Spillm  if (condition)    throw exception;  // The callee'sReloadm is not executed  Reloadm }

Based on the example herein, when an exception is thrown in the calleefunction callee( ), the Reloadm instruction of the callee function'sprologue may not be executed, causing the subsequent Reloadm in thecaller to mismatch with the most recent Spillm of the callee.

Similarly, a mismatch may occur with Setjump/Longjump, as indicatedbelow:

Caller( ) {  Spillm  if (buf=Setjump( )) {   callee( )  // See Callee( )below  } else {   alt code;  } // Reloadm in callee not executed, so Reloadm // This Reloadm is matched with callee's Spillm } Callee( ) { Spillm  if (condition)    Longjump(buf) // Stack unwind performed;Reloadm is not executed  Reloadm }

Since certain programming may lead to mismatched Spillm/Reloadminstructions, in one aspect, a capability is provided to ensure that aparticular Reloadm matches a particular Spillm. The capability includesinvalidating, if need be, a snapshot to be used for recovery and/orensuring that the caller's Reloadm is not satisfied using the callee'sSpillm snapshot. To invalidate a snapshot, a number of techniques may beused, in accordance with aspects of the present invention, includingperforming a Reloadm into, for example, one single register simply toremove a snapshot; unstacking a Spillm snapshot using, for instance, aninvalidate snapshot, Invsnap, instruction; or otherwise, removing asnapshot from the snapshot stack or ignoring a snapshot.

In one example, the number of Reloadm instructions that are skipped isdetermined by scanning the code of the function, and then that number ofsnapshots is invalidated. In one embodiment, code analysis forinvalidated snapshots and snapshot invalidation may be performed inconjunction with conventional unwind processing, e.g., to restoreregisters in the presence of structured exception handling. This isshown in the below code provided in pseudocode notation:

Unwind_and_invalidate ( ) {  Repeat {   Scan to end of this function anddetermine number of Reloadm instructions     skipped and invalidate thatmany snapshots   Do other processing associated with unwind: recovery ofregisters etc   Unwind this (“prev”) function's stack   Set nextprocessing point to caller (“next” function) at the point where it     had called “prev” function  } until target function reached;  Scanin target function until target point and determine number of Reloadm   instructions skipped and invalidate that many snapshots }

Referring to FIG. 12, and as described with reference to the pseudocodenotation, the processor scans the code of the function looking forSpillm/Reloadm pairs, STEP 1200. The number of skipped Reloadminstructions is counted, STEP 1202, and a corresponding number ofsnapshots is invalidated, STEP 1204.

Although one example of managing mismatched pairs is provided, othertechniques may be used.

In accordance with another aspect of the present invention, changes aretracked as they occur, instead of performing the recovery and checkingas described with reference to FIGS. 11A-11C. In this aspect, each timea processor updates memory, a check is made to determine if the updateimpacts the validity of a snapshot. If it does, then the requestedvalues are obtained from memory, instead of the snapshot registers.

In one example, cache lines subject to a store multiple are marked asbeing in a write-set. When interference from another processor isdiagnosed, then a store has occurred to a memory buffer that is subjectto register restoration. In one embodiment, the interference is used toinvalidate in-flight forwarding opportunities. In another embodiment,the cache lines of the write-set may be associated with a correspondingidentifier to indicate which store/load pair is to be excluded fromregister restoration. In at least one embodiment, the write-setindication is not cleared until all intervening store memory operations(or other synchronizing operations) have completed. In anotherembodiment, the write-set for a buffer is not cleared until thecorresponding load has completed. In at least one weak memory orderingembodiment, the write-set reservation is cleared immediately when theload has completed.

In one embodiment, such as in strong memory ordering which may delay theability to complete the first save/restore sequence, two registerrestoration sequences may be in-flight for the same memory location. Forinstance, a function is called, a store multiple is performed forcallee-saved registers, the callee-saved registers are reloaded usingload multiple, the function returns, the function is immediately calledagain, and another store multiple and load multiple occur to the sameaddress.

In one example, the second pair is held until the first one completes.In one embodiment, write-set cache lines can be associated with multiplepairs. In another embodiment, when multiple cache lines are associated,a single bit is used to force the clearance of all store/load registerrestoration pairs. Various examples exist.

Further, in another aspect, interference with stored register in-memorybuffers from local accesses are to be considered. This may beaccomplished by obtaining a base address and a range (either as a lengthor as an end address) for a memory buffer associated with a snapshot,and comparing the address of subsequent store operations against therange of the memory buffer to detect an interference. In one embodiment,this interference test is performed for instructions such asstore-multiple bulk save, whereas interference for individual stores istracked using an indicator associated with a cache line, or cachesubline. In one embodiment, a single snapshot and associated in-memorybuffer range for the most recent store/load pair is maintained. In otherembodiments, additional snapshots and associated in-memory buffer rangesare supported to allow the maintenance of more pairs.

As local and remote accesses are to be checked, in one embodiment,against the buffer address range for each active register restorationsnapshot to detect buffer modifications, address checking can incursignificant area, power and/or delay costs either by implementingconcurrent checking logic or by forcing serial checking of interferenceat the risk of incurring queuing delays as requests are processed. Toreduce these costs, a variety of approaches may be used in conjunctionwith embodiments of aspects of the present invention. In one embodiment,only remote accesses that hit in the first level data cache are comparedagainst tracked memory ranges, when the L1 cache is inclusive. Inanother embodiment, additional filtering is provided by tracking thepresence of buffers in specific cache lines, e.g., using marker bits. Inyet another embodiment, marker bits may be used to indicate activebuffers and buffers may be deactivated responsive to writes to cachelines and subcache lines responsive to a plurality of access typeswithout comparing to tracked address ranges corresponding to snapshots,thereby invalidating snapshots without incurring the overhead ofcomparing tracked ranges corresponding to all snapshots. In yet anotherembodiment, snapshots corresponding to a cache line may be identified bythe cache directory or a separate table, further reducing the number ofcomparisons that are to be performed.

In yet one or more other embodiments, memory addresses may be filteredusing a memory address filter to reduce the number of memory accessesthat are to be compared. A variety of address filters (e.g., addressrange filters, Bloom filters, and so forth) may be used for addressfiltering in conjunction with one or more aspects of the presentinvention. By using address filtering, more address ranges may betracked without a commensurate cost in area, power and delay for memorychecking. Thus, for example, more snapshots, e.g., corresponding tomultiple ranges for deeper levels of a call hierarchy may be trackedusing a variety of filters and digests to give a conservative answer. Inone embodiment, this is achieved by tracking the address of the firstbuffer to the last buffer. This range may, for example, correspond to anumber of stack frames holding memory buffers for register save andrestore in function calls, while filtering out memory requestscorresponding to heap, static variables, file buffers, and so forth. Inanother embodiment, the filter may capture additional information todifferentiate buffer accesses from local variable accesses, and filterlocal variable accesses to further reduce the number of accesses thatare compared against tracked memory buffer ranges corresponding toin-memory register spill buffers. In at least one embodiment, one ormore filters may be periodically reset, in conjunction with invalidatingpending register restoration snapshots, or when no register restorationsnapshots are active. In another embodiment, a range filter is employedin accordance with one or more known snoop filter architectures.

In one embodiment, the interference determination of transactional writesets to detect modifications of buffer memory for store/loadinstructions is used as a filter, and offending remote accesses are thencompared against the exact buffer boundaries used in the core to checkagainst interference from stores of the thread itself.

In one particular example, as shown in FIG. 13A, a data cache 1300includes a plurality of cache lines 1302, and each cache line 1302 (orin another embodiment, selected portions of cache lines) is marked. Forinstance, each cache line or a portion of a cache line in thoseembodiments that mark cache line portions has an address tag 1304indicating the memory address to which the cache line or cache lineportion corresponds; a validity (V) indicator 1306 indicating whetherthe cache line or portion is valid; a dirty (D) indicator 1308indicating whether the data from the cache line or portion is to bewritten back to memory; and a marking (M) indicator 1310, in accordancewith an aspect of the present invention, used to indicate whether thesnapshot is valid for the cache line or cache line portion. Further, thecache line or cache line portion includes the data 1312.

The various indicators, including valid indicator 1306, dirty indicator1308 and marking indicator 1310 are set or reset, as described with theexample techniques described with reference to FIGS. 13B-13D.

For instance, one example of updating the indicators during cache reloadis described with reference to FIG. 13B. Initially, a request isobtained (e.g., received, provided, retrieved, have, determined, etc.)to fetch data from memory into a data cache, STEP 1320. Based on therequest, data is obtained from memory and stored into a cache line, STEP1322. An address tag is computed for the data obtained from memory andstored in the corresponding address tag field 1304, STEP 1324.Additionally, valid indicator 1306 is set to one, since the cache lineis now valid; dirty indicator 1308 is set to zero, since the data wasjust loaded, and thus, not dirty; and marking indicator 1310 is set tozero, since registers have not been stored that have a correspondingsnapshot, STEP 1326.

In addition to updating the indicators during a cache reload, theindicators are also updated during a store into the cache, as describedwith reference to FIG. 13C. Initially, data and an address are obtained(e.g., received, provided, retrieved, have, determined, etc.), STEP1330. A determination is made as to whether the store corresponds to anexisting cache line within the cache, INQUIRY 1332. If not, then thecache reload procedure of FIG. 13B is performed, STEP 1334. However, ifthe store does correspond to a cache line, then the data is stored, STEP1336, and the corresponding dirty indicator is set to one, STEP 1338.Further, if this is a bulk save, e.g., a STMG instruction to spill aplurality of caller-saved or callee-saved registers to a stack frame,INQUIRY 1340, then the marking indicator is set to one, STEP 1342.Otherwise, it is zero.

Moreover, one or more of the indicators may be updated based onreceiving an update request from another processor, as described withreference to FIG. 13D. Initially, data and a memory address are obtained(e.g., received, provided, retrieved, have, determined, etc.), STEP1350. A determination is made as to whether the store corresponds to anexisting cache line within the cache, INQUIRY 1352. If not, then thecache reload procedure of FIG. 13B is performed, STEP 1354. However, ifthe store does correspond to a cache line, then the data is stored, STEP1356, and the marking indicator is set to zero, STEP 1358. The markingindicator is set to zero, since a write access from a remote processormay have modified the in-memory register buffer, thereby making theregister snapshot stale with respect to the in-memory buffer.

In another embodiment, when a marker indicating the presence of a bufferin a cache line or a portion of a cache line is detected during a storeinto the cache, the request range may be compared against the trackedaddresses for snapshots to determine whether a specific accessinterferes with a snapshot. In at least one embodiment, this reduces thenumber of snapshot invalidations when an update corresponds to a portionof a memory buffer's cache line that does not correspond to the memorybuffer. In yet another embodiment, the cache directory or logicassociated therewith may be used to identify specific snapshots of theplurality of active snapshots which correspond to a cache line to reducethe number of interference checks to be performed. In yet anotherembodiment, using marker bits as a filter to reduce the number ofinterference checks is used to filter updates from the local processor.Other possibilities also exist.

One or more of the above cache techniques work in conjunction withregister restoration. One example of a register restoration technique isdescribed with reference to FIG. 14A. Initially, a Load Multiple (LM)instruction (or similar instruction) is obtained (e.g., received,determined, retrieved, provided, have, etc.), STEP 1400. A determinationis made as to whether the Load Multiple instruction corresponds to arestoration request, INQUIRY 1402. This may be determined by checking,for instance, the additional fields of the snapshot stack (e.g., theaddress field) to determine if registers that were previously stored arebeing restored. If the Load Multiple instruction does not correspond toa restoration request, then the load multiple operation is performed,STEP 1404. If the Load Multiple instruction does correspond to arestoration request, then one or more register mappings are recovered,STEP 1406. For instance, one or more snapshots are used to recover thespecified registers. Thereafter, or in parallel, the marking indicator(M) is obtained from the cache line (or cache line portion)corresponding to the registers indicated by the load multiple, STEP1408, and a determination is made as to whether the cache line is markedas unmodified, INQUIRY 1410. If it is marked as unmodified, then afurther determination is made as to whether there are more cache linesor cache portions are to be processed, INQUIRY 1412. If so, processingcontinues to STEP 1408. Otherwise, the register restoration processingis complete.

Returning to INQUIRY 1410, if the marking indicator is marked asmodified (e.g., M is set to 0), then recovery steps are performed (e.g.,reload from the cache), STEP 1414. That is, the values are loaded frommemory, replacing the values of a snapshot.

Another example of register restoration is described with reference toFIG. 14B. In this example, a check is made as to the validity of thesnapshot to be used for restoration. For instance, a Store Multiple mayhave overwritten another Store Multiple. When this occurs, the firstStore Multiple is no longer a valid restoration candidate for a StoreMultiple/Load Multiple used for register restoration. To determine this,the snapshot stack may be traversed to determine if the current snapshotoverlaps a previous snapshot in response to a store multiple request. Inother embodiments, this check is performed for other memory updateoperations, or for other memory update operations when one or morefilter criteria indicate that a check is to be performed. If a match isfound, the entry in the stack of the previous snapshot is invalidated.Thus, in one embodiment, for each entry on the stack, if stack addresseson the snapshot overlap the current store request, the valid indicatorfor that snapshot stack entry is set to invalid. This indicator is thenchecked during restoration processing. One example of this processing isdescribed with reference to FIG. 14B.

Initially, a Load Multiple instruction (or similar instruction) isobtained (e.g., received, retrieved, determined, provided, have, etc.),STEP 1420. A determination is made as to whether the Load Multipleinstruction corresponds to a restoration request, INQUIRY 1422. This maybe determined by checking, for instance, the additional fields of thesnapshot stack (e.g., the address field) to determine if registers thatwere previously stored are being restored. If the Load Multipleinstruction does not correspond to a restoration request, then the loadmultiple operation is performed by loading the plurality of registers tobe loaded by the Load Multiple instruction from memory, STEP 1424. Ifthe Load Multiple instruction does correspond to a restoration request,then a determination is made as to whether one or more restorationsnapshots to be used are valid (i.e., to confirm that the in-memorybuffer has not been overwritten), INQUIRY 1426. If the one or more validindicators indicate that the one or more restoration snapshots arevalid, then one or more register mappings are recovered, STEP 1428. Forinstance, one or more snapshots are used to recover the specifiedregisters. Thereafter, or in parallel, the marking indicator (M) isobtained from the cache line (or cache line portion) corresponding tothe registers of load multiple, STEP 1430, and a determination is madeas to whether the cache line is marked as unmodified, INQUIRY 1432. Ifit is marked as unmodified, then a further determination is made as towhether there are more cache lines or cache portions are to beprocessed, INQUIRY 1434. If so, processing continues to STEP 1430.Otherwise, the register restoration processing is complete.

Returning to INQUIRY 1432, if the marking indicator is marked asmodified (e.g., M is set to 0), then recovery steps are performed (e.g.,reload from the cache), STEP 1436. That is, the values are loaded frommemory, replacing the values of a snapshot.

In accordance with a further aspect, another mechanism for trackingmodifications to memory includes using transactional memory hardware totrack changes to memory. Transactional memory has the capability totrack interference, to track access to a range of memory locations thatcorrespond to transactional state, and that capability may be used totrack whether the buffer corresponding to the in-memory image of thesaved registers is being modified. The transactional memory facility maytrack whether an in-memory change affects a register included in aparticular snapshot.

A capability is provided, in one aspect, for saving registers fortransactional memory rollback recovery and function call registerpreservation using a shared register restore capability. The facility isinitiated by a bulk-save indicating event, e.g. receiving a bulk-saveindicating instruction. In one embodiment, a TBegin (begin transactionalexecution instruction) is a first indicating instruction, and a StoreMultiple or Spill Multiple instruction is a second indicatinginstruction.

If a store multiple is received, in one embodiment, stores areimmediately performed, but incremental register checkpointing is alsoperformed. For Spill Multiple, only in-core checkpointing may beperformed, in one example.

Based on receiving an indicating event, a test is made as to whether thepresent request is compatible with pre-existing requests. Whencompatibility is determined, processing proceeds. Otherwise, if theinitial request corresponds to a transactional memory rollback request,a bulk save is directly performed, and in-core register preservation isused exclusively for transactional memory. If the first request is aregister save request, then in-core register preservation for a functioncall bulk restore is terminated, and transactional memory saving isinitiated.

When a restore event occurs, the subset of tracked registers which havebeen saved are restored. In one embodiment, only modified registers aresaved. In another embodiment, all tracked registers are saved.

In accordance with one embodiment, register restoration is implementedas a modified transactional execution register rollback operation. Forinstance, when a bulk store is identified, a snapshot is made of theregisters to be spilled into transactional memory (TM) registerrestoration state. Further, in one example, when a bulk restore isidentified, the register snapshot is restored in a manner otherwiserestored during a transaction abort.

In one example, when multiple register snapshots are not supported, aprevious TM register snapshot is discarded when a new bulk store isidentified, and the most recent bulk store can be received using the TMregister restoration. In another embodiment, e.g., an embodimentsupporting nested transactions, multiple spill snapshots are stored inregister restoration snapshots corresponding to multiple nestedtransactions.

When a transaction is encountered, and storage for another registerrecovery state is available (e.g., when nested transactions aresupported), a next register recovery level is used. Otherwise, aprevious register snapshot corresponding to a bulk store (e.g., either amost or least recent snapshot) is invalidated, to save a TM registerrestoration state instead. In another embodiment, a nested transactionmay be flattened, into an outer transaction to avoid deallocating a bulkstore snapshot.

In one embodiment, when the TM facility is enabled, using the TMregister recovery mechanism for spill register restoration is disabled.Other variations are possible.

In one embodiment, a transaction rollback, transaction failure,transaction interference, transaction abort, or other operationterminating and invalidating an operation triggers a restore event, whenthe initiating event is a TBegin. Further, a Load Multiple or Reloadmultiple is considered a restore event, when the initiating event is aStore Multiple, Spill Multiple request, or similar request.

Tracking of state modification ends, and a state preservation operationis terminated either when a transaction fails (a transaction rollback,transaction failure, transaction interference, transaction abort, orother operation terminating and invalidating an operation) or succeeds(Tend—transaction end occurs), when bulk saving has been initiated byTBegin. A register bulk reload is performed when the register bulk savehas been initiated by a Store Multiple, Spill Multiple, or similarrequest.

In at least one instance, the saving of registers occurs incrementally,and the incrementally saved registers may be restored.

Further details relating to transactional memory and registerrestoration are described with reference to FIGS. 15A-15E.

Referring initially to FIG. 15A, processing associated with initiating asnapshot based on a TBegin instruction is described. In one embodiment,a TBegin instruction is obtained (e.g., received, provided, determined,retrieved, have, etc.), STEP 1500. The TBegin instruction initiates atransaction, and, in one example, as shown in FIG. 15B, includes, forinstance, an operation code (opcode) field 1510 that includes an opcodespecifying a transaction begin operation; a base field (B₁) 1512; adisplacement field (D₁) 1514; and an immediate field (I₂) 1516.

When the B₁ field is nonzero, the contents of the general registerspecified by B₁ 1512 are added to D₁ 1514 to obtain a first operandaddress.

When the B₁ field is nonzero, the following applies, in one example:

-   -   When the transaction nesting depth is initially zero        (transactions may be nested), the first operand address        designates the location of a 256 byte transaction diagnostic        block, called a TBEGIN-specified TDB into which various        diagnostic information may be stored if the transaction is        aborted.

The bits of I₂ field 1516 are defined as follows, in one example:

General Register Save Mask (GRSM): Bits 0-7 of the I₂ field contain thegeneral register save mask (GRSM). Each bit of the GRSM represents aneven-odd pair of general registers, where bit 0 represents registers 0and 1, bit 1 represents registers 2 and 3, and so forth. When a bit inthe GRSM of the outermost TBegin instruction is zero, the correspondingregister pair is not saved. When a bit in the GRSM of the outermostTBegin instruction is one, the corresponding register pair is saved in amodel dependent location that is not directly accessible by the program.

If the transaction aborts, saved register pairs are restored to theircontents when the outermost TBegin instruction was executed. Thecontents of all other (unsaved) general registers are not restored whena transaction aborts.

The general register save mask is ignored on all TBegins except for theoutermost one.

Allow AR Modification (A): The A control, bit 12 of the I₂ field,controls whether the transaction is allowed to modify an accessregister.

Allow Floating Point Operation (F): The F control, bit 13 of the I₂field, controls whether the transaction is allowed to execute specifiedfloating point instructions.

Program Interruption Filtering Control (PIFC): Bits 14-15 of the I₂field are the program interruption filtering control (PIFC). The PIFCcontrols whether certain classes of program exception conditions (e.g.,addressing exception, data exception, operation exception, protectionexception, etc.) that occur while the CPU is in the transactionalexecution mode result in an interruption.

The I₂ field may include more, fewer or different controls thandescribed herein.

Returning to FIG. 15A, based on obtaining the TBegin instruction, adetermination is made as to whether a register restoration facility,e.g., the register restoration snapshot facility, is in active use,INQUIRY 1502. This may be determined based on, for instance, a facilityindication being set to a particular value (e.g., 1) or by checkingwhether such snapshots are in use, etc. If the facility is in activeuse, register restoration is deactivated and in-memory registerrestoration buffer tracking is disabled, STEP 1504. This is because theTBegin takes priority, in this example Thereafter, or if the registerrestoration facility is not active, a transactional rollback snapshot iscreated, STEP 1506. For instance, a snapshot of the registers to besaved as indicated by the TBegin instruction (e.g., specified by GRSM)is taken. Further, the tracking of transactional state interference isinitiated, STEP 1508. For instance, transactional state buffer andTBegins are tracked.

In a further aspect, a snapshot may be taken based on a register saverequest, as described with reference to FIG. 15C. A register saveindication (e.g., Store Multiple) is obtained (e.g., received, provided,have, retrieved, determined, etc.), STEP 1520. A determination is madeas to whether the register restoration facility is in use fortransactional execution (e.g., by checking an indicator), INQUIRY 1522.If it is in use for transactional execution, then the register state isstored in memory, STEP 1530. However, if the register restorationfacility is not in use for transactional execution, then a furtherdetermination is made as to whether the register restoration facility isin use for register restoration of incompatible requests (e.g., ofdifferent registers), INQUIRY 1524. If it is in use for incompatiblerequests, then processing continues to STEP 1530, in which the registerstate is stored in memory.

However, if the register restoration facility is not in use fortransactional execution or for register restoration for incompatiblerequests, a register restoration snapshot is created (e.g., a snapshotof the registers specified by the Store Multiple), STEP 1526, andinterference tracking for in-memory register restoration buffers isinitiated using, for instance, logic of the transactional facilityadapted to identify interference with a transaction's transactionalstate in memory, STEP 1528. Further, the register state is stored inmemory, STEP 1530.

In accordance with the use of the transactional state interferencetracking logic for tracking changes to a memory buffer in accordancewith an aspect of the present invention, the in-memory register bufferof STEP 1530 is tracked for interference by the interference checkinglogic. Consequently, when a remote access to the in-memory buffercontaining a copy of the saved registers is received, interference isregistered. In accordance with one aspect of the present invention, wheninterference is registered, no rollback occurs when the interferencetracking logic is used to determine modification of register savebuffers. In accordance with this aspect of the present invention, wheninterference is detected, the in-processor register snapshot is not usedwhen the registers are being restored, and the registers are insteadretrieved from the in-memory register save buffer. In accordance with atleast one embodiment, additional tracking is performed to trackin-memory register save buffer modification by processor-local memorywrite instructions, e.g., by comparing writes to the address range ofone or more memory buffers in accordance with one aspect of the presentinvention.

Additionally, in one aspect, a snapshot is recovered based on atransactional rollback, as described with reference to FIG. 15D. Arollback request (e.g., responsive to interference with a transaction'stransactional state or execution of a Transaction Abort (TAbort)instruction) is obtained (e.g., received, have, provided, retrieved,determined, etc.), STEP 1540. The state is rolled back to the startingpoint of the transaction, STEP 1542. In accordance with this rollback ofthe transaction, the register state is restored to the state at thebeginning of the transaction (i.e., where the TBegin was executed tocreate the rollback snapshot for transactional execution in accordancewith FIG. 15A). Performing a transactional rollback includes, forinstance, restoring a program counter and canceling the in-memoryeffects of an aborted transaction in accordance with the knownimplementation of transactional memory. Transactional rollback isindicated as inactive, STEP 1544, and transactional memory interferencetracking is deactivated, STEP 1546.

Further, in one aspect, a snapshot is recovered based on a registerrestoration restore request, as described with reference to FIG. 15E. Aregister restoration restore request (e.g., Load Multiple) is obtained(e.g., received, provided, have, etc.), STEP 1550, and a determinationis made as to whether an in-core register restoration facility isactive, INQUIRY 1552. If it is not active, then recovery is performedfrom memory state, STEP 1554. However, if in-core register restorationis active, then a further determination is made as to whether there isor has been interference with an in-memory register restoration buffer,INQUIRY 1556. If there is interference, then register restorationin-memory tracking is deactivated, STEP 1558, and processing continuesto STEP 1554.

Should there be no interference with the in-memory register restorationbuffer, the indicated registers are recovered from in-core state (e.g.,a snapshot), STEP 1560. In one example, the program counter andin-memory effect rollback are excluded. Register restoration in-memorytracking is deactivated, STEP 1562.

As described above, the transactional memory facility may be used totrack changes. In one aspect, transactional state is re-used bymirroring the actions used for transactional execution to achieve thegoals of register restoration; however, transactional rollbackprocessing and register restoration are triggered by differentinstructions; they are mutually exclusive in that when one is active forrestoration, the other is not; and register restoration (e.g., based ona LM) does not recover the program counter or undo in-memory changes, asdoes transactional rollback processing, as examples.

In one or more further aspects, tracking of memory changes is performedin conjunction with a snapshot stack. As described above, a snapshotstack provides a list of buffers since each entry includes an address oraddress range of its buffer. Thus, each time there is a write, theaddress or address range of the write is compared against the address oraddress range of the buffers in the stack. In accordance with at leastone embodiment, the snapshot stack used for tracking memory save changescorresponds to and is shared with a snapshot stack in accordance withFIG. 6 used for storing snapshot IDs created by register save operationsfor corresponding register restore operations in accordance with aspectsof the present invention. Examples of various techniques used to trackmemory changes are described with reference to FIGS. 16A-16D.

A first technique described with reference to FIG. 16A relates to takinga new snapshot. For instance, in one embodiment, a Store Multiple (STM)instruction (or similar instruction) is obtained (e.g., received,provided, have, retrieved, determined, etc.) by the processor, STEP1600, and a determination is made as to whether there is an availableentry in the snapshot stack, INQUIRY 1602. If there is no availableentry, then a snapshot stack overflow is performed, STEP 1604. Forexample, an error is indicated. If there is an available entry, thetop-of-stack pointer is updated (e.g., incremented by 1), STEP 1606.

Further, a snapshot is created, STEP 1608, and a snapshot identifier isstored in the entry, STEP 1610. Additionally, the contents of theregisters specified by the Store Multiple are stored in memory, STEP1612, and the memory address range of where the contents are stored isincluded in the entry (e.g., address), STEP 1614. Further, the validindicator is set (e.g., to 1) in the entry, STEP 1616, and other fields,if any, are also updated, STEP 1618.

In addition to the above, a technique for tracking changes if executingan individual store request, is described with reference to FIG. 16B. Inthis embodiment, for each store of this processor, a check of the stackis performed to determine whether there is any overlap. Initially, amemory write request with a store address is obtained (e.g., received,is provided, have, determined, retrieved, etc.) by this processor, STEP1620. Then, for each entry in the snapshot stack, STEP 1622, adetermination is made as to whether the address range for this entrymatches the store address, INQUIRY 1624. If so, then the valid bit forthe current entry is reset (e.g., to zero), STEP 1626. Thereafter, or ifthe address range for this entry does not match the store address, acheck is made as to whether there are more entries in the snapshot stackto be processed, INQUIRY 1628. If there are more entries, thenprocessing continues to STEP 1622. Otherwise, processing ends.

Similarly, referring to FIG. 16C, checks are performed for writerequests received from other processors. Initially, a processor obtains(e.g., received, provided, retrieved, determined, have, etc.) a remotememory write request with a store address from another processorrequesting exclusive access or a data update, STEP 1640. Then, for eachentry in the snapshot stack, STEP 1642, a determination is made as towhether the address range for this entry matches the address of thestore request, INQUIRY 1644. If so, then the valid bit for the currententry is reset (e.g., to zero), STEP 1646. Thereafter, or if the addressrange for this entry does not match the address of the store request, acheck is made as to whether there are more entries in the snapshot stackto be processed, INQUIRY 1648. If there are more entries, thenprocessing continues to STEP 1642. Otherwise, processing ends.

While the techniques of FIGS. 16B and 16C are described with respect tochecking the addresses of all entries in a snapshot stack, in optimizedembodiments, the number of writes to be compared and entries on thesnapshot stack may be reduced to reduce the cost of performing the testfor snapshot invalidation. For example, a variety of filteringtechniques, such as snoop filters, are to be compared against thesnapshot stack entries. Some example filters may be range filters,filtering by way of mark bits associated with a data cache, e.g., inconjunction with a cache in accordance with FIG. 13A, and so forth. Inanother optimized embodiment, a subset of stack entries may beidentified, e.g., by determining which entries are to be tested based onan address received. In one such embodiment, snapshot entries may haveentry indicators associated to cache lines containing a correspondingmemory buffer.

In a further embodiment, a technique for performing register restorationbased on receipt of a bulk restore is described with reference to FIG.16D. Initially, a Load Multiple (LM) instruction or similar instructionis obtained (e.g., received, provided, retrieved, have, determined,etc.) by the processor, STEP 1660. The processor obtaining the requestdetermines whether the load multiple operation corresponds to arestoration request, INQUIRY 1662. If it does not correspond to arestoration request, then the load multiple operation is performed, STEP1664. However, if the load multiple operation corresponds to arestoration request, then a determination is made as to whether thecorresponding restoration snapshot is valid, INQUIRY 1666. If it isvalid, then one or more register mappings are recovered using thesnapshot, STEP 1668. If it is not valid, the recovery is performed usinganother technique, such as loading the values from a memory buffer,either from a cache or system memory, STEP 1670.

Although various embodiments and techniques are provided herein fortracking memory changes, other variations, embodiments and/or techniquesmay be provided without departing from a spirit of aspects of thepresent invention.

In accordance with another aspect of the present invention, a capabilityis provided to manage the losing of a portion of a snapshot. Registerrestoration from in-core values represents a technique to recover valuesfrom in-core data stores. In one example, these data stores are sharedwith micro-architectural structures used to implement other processormechanisms (e.g., branch misprediction recovery and precise exceptions).Examples of the in-core data stores are recovery files and registerrename maps (e.g., snapshots). However, in one embodiment, not allvalues can be restored. For example, some registers may no longer beavailable to recover from, because they have been reallocated to holdnew architected values. In one embodiment, values that have beenoverwritten are tracked, e.g., by allocation time tracking or trackingliveness.

In one example, for the last allocation (or in another embodiment, writetime) time tracking, each physical register is associated with a timewhen it was last allocated (written) to hold an architected value. Then,if that allocated time (tag) is later than the time (tag) of the createdrestore point, the value is not available.

In a further embodiment, a bitmap of all (or a subset of) values iscreated, or a register rename map is updated. Each time a registerbecomes unavailable, it is removed from a bit map, or a register renamemap, so that during recovery, the unrestorable registers are known. Inone embodiment, the bit map or register rename map corresponds to aregister restoration snapshot.

In accordance with an aspect of the present invention, there is provideda hybrid technique for register restoration. Register restoration fromin-core values is provided when in-core values can be determined to beavailable, in accordance with a liveness/availability trackingmechanism. The remaining values are loaded from memory.

One embodiment of handling a restoration request, in accordance with anaspect of the present invention, is described with reference to FIG. 17.Initially, a restoration request (e.g., a Load Multiple instruction) isobtained (e.g., received, provided, retrieved, determined, have, etc.),STEP 1700, and based thereon, the processor determines whether thesnapshot corresponding to the registers to be restored is valid, INQUIRY1702. If the snapshot is invalid, then the values are restored frommemory, STEP 1704. However, if the snapshot is valid, for each registerto be restored, STEP 1706, a determination is made, e.g., via timetracking, a bit map, etc., as to whether the particular register can berestored from the snapshot, INQUIRY 1708. If the register can berestored from the snapshot, then it is restored from the snapshot, by,for instance, updating a rename map, STEP 1710. However, if the registercannot be restored from the snapshot, then the register is restored frommemory, e.g., by allocating a new rename register to the correspondingarchitected register and loading its value from memory, STEP 1712.

In one embodiment, a determination is made as to whether there are moreregisters to be restored, INQUIRY 1714. If there are one or moreregisters to be restored, processing continues to STEP 1706.

As described above, in this aspect of restoring registers, if an in-corevalue exists, the in-core value is retrieved, and if the in-core valuedoes not exist, the value is loaded from memory.

Register rename restoration captures processor state for laterrestoration based on explicit or inferred restoration point indicators(e.g., Spillm instruction, Store Multiple instruction, Store Multipleinstructions using one of a well-defined base register, such as a framepointer or stack pointer, etc.). Further, register restoration isperformed upon an explicit or an inferred restoration request (e.g.,Reloadm instruction, Load Multiple instruction, Load Multipleinstructions using one of a well-defined base register, such as a framepointer or stack pointer, etc.).

A restore point used by one application, however, may be incorrectlyused by another application after a context switch. In particular, thismay even occur when the identification of snapshot locations identify aparticular binary, e.g., even using detailed fingerprints of binaries,as multiple instances of the same binary or library may be executing, ora fingerprint may be matching, and a restoration point from a functionin one context may be used to perform restoration in the function ofanother process of the same binary or library matching the fingerprint.Thus, in accordance with an aspect of the present invention, an explicitand/or an inferred context switch (e.g., switch from one application orfunction to another application or function, etc.) cognizance isincluded within a processor. Based on detection of a possible contextswitch, all or a subset of restoration points are invalidated, in oneembodiment.

In one example, an invalidation instruction is provided that is used toinvalidate one or more restoration points, e.g., as part of a contextswitch routine. In one embodiment, this instruction is executed by anoperating system's context switch code. In another embodiment, based ona permission level changing indicating a switch to another applicationmodule (e.g., the kernel), and thus, the possible future switch toanother application, at least one restoration point is invalidated. In afurther embodiment, this does not occur so as to allow registerrestoration points to be used in the presence of functions which makesystem calls, when such system calls may be short, e.g., the POSIXgetpid system call).

In yet a further embodiment, a change of a value in a registerindicative of a process (e.g., one or both of LPID (logical partitionid) and PID (process id)) is used to identify a task switch. In anotherembodiment, register snapshots may be associated to indicia valuesindicative of a particular process, and an indicia match between theindica associated with a snapshot ID and the indicia of a currentprocess requesting register restoration is to be confirmed beforerestoring registers using a register restoration snapshot. A variety ofindicia may be used in embodiments, such as the LPID and PID in oneexample embodiment.

Moreover, in one embodiment, the invalidation instruction may also beused for non-traditional control flow in programs, e.g., forsetjump/longjump handling, or C++/Java structured exception processing.Other examples also exist.

Further details regarding example techniques for recognizing a contextswitch and invalidating one or more snapshots (or portions thereof) aredescribed below with reference to FIGS. 18A-18C.

In the example of FIG. 18A, an invalidate restoration snapshotinstruction is used. This instruction is, for instance, an architectedinstruction having an operation code indicating it is an invalidaterestoration snapshot instruction, and one or more fields used toindicate or determine one or more snapshots to be invalidated. Sincethis is a new instruction, the operating system, in one example, ismodified to recognize and use the instruction.

Referring to FIG. 18A, the processor obtains (e.g., received, provided,retrieved, determined, have, etc.) an invalidate restoration snapshotinstruction, STEP 1800. This instruction may be initiated based ondetermining a context switch, as described herein. Based on obtainingthe instruction, the processor clears at least one entry on the snapshotstack based on an indication by the instruction of the one or moresnapshots to be invalidated, STEP 1802. Additionally, in one example,one or more of the marking bits in the cache entries corresponding tothe addresses indicated in the one or more snapshots that areinvalidated are cleared (e.g., set to zero), STEP 1804.

In FIG. 18B, instead of using an architected instruction that requiresan update of the operating system, heuristics are used to determinewhether there is a context switch, and therefore, one or more snapshotsare to be invalidated. Referring to FIG. 18B, initially, a determinationis made as to whether the processor detects changes in the processorstate that are indicative of a context switch, INQUIRY 1820. Forinstance, has a program status word (PSW) changed or has the pointer toaddress translation tables changed, both of which may be indicating acontext switch. If a context switch is indicated by one of thesemechanisms or another mechanism, the processor clears at least one entryon the snapshot stack of the one or more snapshots to be invalidated,STEP 1822. Additionally, in one example, one or more of the marking bitsin the cache entries corresponding to the addresses indicated in the oneor more snapshots that are invalidated are cleared (e.g., set to zero),STEP 1824. Otherwise, if a context switch is not indicated, thisprocessing ends.

In yet a further embodiment, the use of the invalidation instruction orheuristics may be dynamically selected by the processor. Referring toFIG. 18C, the processor dynamically selects either the invalidaterestoration snapshot instruction or the heuristic technique fordetermining whether there has been a context switch, STEP 1830. Forinstance, if the operating system is at a version level that does notrecognize such an instruction, then the heuristic approach is selected.However, if the operating system does recognize the instruction, then itmay wait for issuance of the instruction or use heuristics to determineif a snapshot is to be invalidated. If it is determined thatinvalidation is to be performed, either by receiving the instruction orheuristically, INQUIRY 1832, then the processor clears at least oneentry on the snapshot stack to be invalidated, STEP 1834. Additionally,in one example, one or more of the marking bits in the cache entriescorresponding to the addresses indicated in the one or more snapshotsthat are invalidated are cleared (e.g., set to zero), STEP 1836.Otherwise, if a context switch is not indicated, this processing ends.

In one aspect, register preservation occurs incrementally for functioncall bulk state preservation, and registers are not saved to memoryimmediately upon receiving, for instance, a register Spill Multipleinstruction. Correspondingly, registers are saved when in-corepreservation is terminated due to, e.g., a switch to transactionalmemory preservation. This may be implemented, for instance, using astate machine of transitions.

In another aspect, when incremental state preservation is performed fora Store Multiple, as an example, a memory range of Store Multiples iswatched by, e.g., marking it as being a part of a write-set even if ithas not been written.

In one or more aspects, multiple bulk save requests may be received, andtherefore, it is to be determined if a given request is compatible withprocessing that is being performed. For instance, if no pre-existingbulk save request is present, a new request that is received iscompatible. If a pre-existing bulk save request is present, and a bulksave request is received, a further determination is made: If theregisters are mutually exclusive, they may be considered compatible. Ifthey refer to one or more registers, and an intervening modification hasoccurred, they may be considered compatible. If hardware supportsmultiple bulk save/restores, they may be considered compatible.

If a pre-existing transactional memory rollback request exists, and atransactional memory rollback request is received, a furtherdetermination is made: If nested transactions are implemented asflattened transactions, they are compatible. If nested transactions aretrue nested transactions, and a context (e.g., snapshot or other savingof state) is available, they are compatible. If no more storage to saveadditional state remains, flattening of nested transactions may beselected to achieve compatibility.

If a pre-existing transactional memory rollback request is present, anda register save request is received, further tests are performed: Ifmultiple bulk requests are supported, and storage is available foradditional state, they may be considered compatible. If no interveningmodifications have occurred to registers that are shared betweentransactional memory rollback set and Store Multiple set, they arecompatible.

If a pre-existing bulk save request is present, and a transactionalmemory rollback request is received, further tests are performed: Ifmultiple bulk saves are supported, and storage is available foradditional state, they may be considered compatible. If no interveningmodifications have occurred to registers that are shared betweentransactional memory rollback set and Store Multiple set, they arecompatible.

One example of processing associated with managing one or more snapshotsbased on receiving a TBegin instruction is described with reference toFIG. 19A. A TBegin instruction is obtained (e.g., received, provided,have, retrieved, determined), STEP 1900. A determination is made as towhether a register restoration facility is in active use, INQUIRY 1902.If a register restoration facility is not in active use, then atransactional rollback snapshot is created (e.g., a snapshot is taken ofthe registers indicated to be saved by the TBegin instruction), STEP1912, and tracking of transactional state interference is initiated(e.g., tracking whether an in-memory write corresponds to one of theregisters of the snapshot), STEP 1914.

Returning to INQUIRY 1902, if a register restoration facility is inactive use, then a determination is made as to whether a snapshotcompatible with the transactional request exists (e.g., are theregisters the same), INQUIRY 1904. If the snapshot is compatible withthe request, then the register restoration snapshot is used fortransactional execution, STEP 1906. However, if the snapshot is notcompatible with the request, then a further check is made as to whethermore snapshots may be made (e.g., is there room in the snapshot stack),INQUIRY 1908. If more snapshots can be made, then processing continuesto STEP 1912. Otherwise, the register restoration snapshot isdeactivated, STEP 1910, and optionally, the snapshot is stored in memoryif, for instance, it is not previously stored. In another embodiment,there are separate stacks for recovery snapshots and restorationsnapshots.

Another example of processing associated with managing one or moresnapshots is described with reference to FIG. 19B. In this example, aregister save indication request (e.g., a Store Multiple) is obtained(e.g., received, provided, determined, retrieved, have, etc.), STEP1920. A determination is made as to whether the register restorationfacility is in use for incompatible requests, INQUIRY 1922. If thefacility is in use for such requests, a further determination is made asto whether storage is available for additional snapshots (referred toherein as snapshot contexts), INQUIRY 1924. If not, then the registerstate is stored in memory, STEP 1932. However, if there are moresnapshot contexts available or the register restoration facility is notin use for incompatible requests, then a register restoration snapshotis created, STEP 1926. Further, interference tracking for an in-memoryregister restoration buffer is initiated, STEP 1928. Optionally, theregister state is stored in memory, STEP 1932.

In a further aspect, a capability is provided to coalesce a plurality ofload and store instructions to determine a range of registers to berestored. For example, the processor is adapted to recognize a sequenceof individual load and store operations which may be coalesced into asingle restore and save operation, respectively. Coalescing may beperformed using a variety of techniques.

In accordance with one or more embodiments of aspects of the presentinvention, coalescing sequences of loads and stores is used to enablethe use of the register restoration techniques described herein inconjunction with legacy code sequences without bulk save and restoreinstructions, such as STMG and LMG for z/Architecture general purposeregisters, or STMW and LMW for Power ISA fixed point registers. Inparticular, this includes the bulk save of some register types in thez/Architecture and Power ISA, such as, inter alia, floating pointregisters in z/Architecture and Power ISA, and vector registers in PowerISA for which no store multiple and load multiple floating pointinstructions exist. Furthermore, some architectures do not provide storemultiple and load multiple instructions for any register types

In one embodiment, each store request may start a store multiplecoalescing sequence that may be recognized In another embodiment, onlycertain store requests trigger a coalescing sequence that may berecognized. This is to, for instance, avoid power and other overheadassociated with operating additional logic. In one or more embodiments,a coalescing sequence is started only by store requests that use acertain register, e.g., a frame point, stack pointer, or otherdistinguished register as a base register. In another embodiment, atleast a first and second instruction with adjacent addresses (based onthe instruction image, i.e., same base and displacement differencecorresponding to data size) start a sequence. Other examples are alsopossible.

In one embodiment, when a first store of a coalescing sequence occurs,the state of the register file (e.g., the register file map, etc.) issnapshot. A bit mask is initialized, in one example, reflecting whichregisters may be restored from a snapshot. Subsequent writers toregisters indicate in the bit mask that a particular register no longercorresponds to the value in the snapshot. Thus, when a subsequent storerefers to such a register, it may either be separately performedindependent of the coalescing sequence, start a new coalescing sequence,or both. Similarly, one embodiment may require that a store be at anoffset commensurate with contiguous storage (e.g., if the first storeoccurred at displacement d1 for register r1, then register r2 is to bestored at displacement d2=d1+(word size)*(r2−r1) using the same base).In other embodiments, a strict order may be imposed on the instructionsequence, e.g., each store is to store the register R(N+1) if theprevious instruction stored register R(N), enabling a single counter totrack the embodiment. Other variations are possible. In one embodiment,heuristics are used to limit the stores which may trigger the creationof a snapshot.

In another embodiment, coalescing of individual stores and loads intogroups of stores and loads which may then trigger state snapshotting andregister restoration in accordance with an aspect of the presentinvention is performed in conjunction with group formation. Inaccordance with one aspect, instructions are grouped to keep adjacentstores without intervening modifications of registers in the storerange. As one example, control logic ensures that stores occur in acontiguous manner, e.g., at d2=d1+(word size)*(r2−r1) for displacementsd1 and d2 associated to a common (unmodified) base (and in one example,no index, or the same unmodified index).

In one embodiment, loads are coalesced in a similar manner as stores. Inanother embodiment, loads are executed singly wherein for each load acorresponding rename register is retrieved from a register snapshotindividually because in at least one embodiment, the overhead ofregister restoration is primarily associated with storing andmaintaining a mechanism to retrieve stored values for in-corerestoration.

The recognizing is performed in one of a pre-decode, a group formationand a decode stage. In other embodiments with a trace cache, a loopcache or other such cache, it may operatively be coupled to logicadapted to creating and/or optimizing a loop, trace or iop (internaloperation) cache.

In one aspect, a technique for restoring registers from an in-core valuepool includes recognizing a sequence of adjacent individual storeinstructions of adjacent registers, creating and maintaining a singlesnapshot for restoration, and using a single snapshot to bypassregisters from the single snapshot.

One embodiment of coalescing individual register store requests forcreation of a snapshot is described with reference to FIG. 20A. A singlestore request is obtained (e.g., received, have, provided, retrieved,determined, etc.), STEP 2000. A determination is made as to whether thisis a possible start of a store sequence (e.g., a multi-store/registerspill sequence), INQUIRY 2002. This may include checking for a subset ofregisters, addressing modes, addressing ranges, or another indication ofa register spill sequence. If it is determined that it is not the startof a possible store sequence, then one or more stores are performed,STEP 2004. However, if it is a possible start of a store sequence, thena prospective register restoration snapshot request with the presentstore request is tracked, STEP 2006.

A determination is made as to whether a next instruction is acontinuation of the store request, INQUIRY 2008. If the next instructionis a continuation of a store request, then the next instruction is addedto the store request, STEP 2010. A check is made as to whether there aremore instructions to be processed, INQUIRY 2012. If so, processingcontinues to INQUIRY 2008.

If the next instruction is not a continuation of a store request,INQUIRY 2008, then a determination is made as to whether a registerrestoration snapshot is desirable, INQUIRY 2014. That is, does theprospective snapshot have enough registers to make the snapshotworthwhile? If a snapshot is desirable, then a register restorationsnapshot technique is performed to create a snapshot, STEP 2016.However, if a snapshot is not desirable, then one or more stores areperformed, STEP 2018. In accordance with at least one embodiment,snapshots saving a certain minimum number of registers are desirable, soas to amortize the cost of creating and managing a snapshot. Thus, in atleast one embodiment, when a prospective snapshot has more than a setthreshold of registers, it is considered desirable. In anotherembodiment, desirability of a snapshot is estimated based on possibleruntime improvement. In at least one embodiment, when a prospectivesnapshot offers more than a set threshold of runtime improvement, it isconsidered desirable. Other possibilities also exist.

One embodiment of coalescing individual register restore requests isdescribed with reference to FIG. 20B. A single load request is obtained(e.g., received, have, retrieved, determined, provided, etc.), STEP2040. A determination is made as to whether this is a possible start ofa register restore sequence, INQUIRY 2042. This may include checking fora subset of registers, addressing modes, addressing ranges, or anotherindication of a register reload. In at least one embodiment, INQUIRY2042 includes a test whether the load request corresponds to the mostrecent register snapshot with respect to the register being restored andthe specified in-memory storage location. If it is determined that it isnot the start of a possible restore sequence, then one or more loads areperformed, STEP 2044. However, if it is a possible start of a restoresequence, then a prospective register restoration request with thepresent load request is tracked, STEP 2046.

A determination is made as to whether a next instruction is acontinuation of the restore request, INQUIRY 2048. If the nextinstruction is a continuation of the restore request, then the nextinstruction is added to the restore request, STEP 2050. A check is madeas to whether there are more instructions to be processed, INQUIRY 2052.If so, processing continues to INQUIRY 2048.

If the next instruction is not a continuation of the restore request,INQUIRY 2048, then a determination is made as to whether the restorerequest(s) match the register restoration snapshot, INQUIRY 2054. If so,then a register restoration snapshot restore technique is performed,STEP 2056. Otherwise, one or more loads are performed, STEP 2058.

In one or more aspects, when a Spillm instruction is encountered, anin-core register restoration snapshot is made. Additionally, spilledregisters are stored to a temporary location (commonly the stack frameof the current function) in case the in-core register restorationsnapshot is invalidated. Contents of the Spillm registers are placed ona store queue and written to memory.

The registers are restored from the in-core register restorationsnapshot by, for instance, the Reloadm instruction, if the registersnapshot is valid. Otherwise, Reloadm reloads the values from memory(e.g., the temporary storage area in the current function's stackframe).

In one aspect, when the Reloadm instruction completes, values to bestored based on a Spillm instruction may still be queued in the storequeue to be written to caches and eventually system memory. Once theReloadm has completed, no further reads to the buffer will occur.Consequently, these values use up valuable space in the store queue andcause time delay for subsequent stores in the store queue as well asenergy consumption while processing stores that are known to be useless.Thus, in one example, when the Reloadm instruction completes, storequeue entries corresponding to the Spillm/Reloadm save/restore sequenceare invalidated. For instance, they are removed from the store queue, orwhen they come to the head of the store queue to be committed to thememory hierarchy, they are not written. Other examples also exist.

In yet another embodiment, when a remote cross-invalidate (XI) isreceived, store queue entries identified with Spillm are not provided.Further, in another embodiment, when a remote XI is received, storequeue entries identified with a Spillm for which the Reloadm hascompleted are not provided.

Aspects of managing the store queue are controlled by store queue writeback logic, which is augmented in accordance with one or more aspects ofthe present invention. As shown in FIG. 21A, in one example, a storerequest (SRQ) write back logic 2100 is located in a store queue 2102that further includes address information 2104 and data 2106 for eachstore queue entry. Store queue 2102 receives store requests 2108 from aload/store unit (LSU) 2110 of a central processing unit (CPU) 2112. CPU2112 further includes, for instance, an instruction fetch unit (IFU)2114 that fetches instructions, which are decoded using an instructiondecode unit 2116. The decoded instructions may be executed via one ormore execution units 2118.

As indicated, the load/store unit places store requests 2108 on storequeue 2102. Store request write back logic 2100 performs a write back toa memory subsystem 2122, which may include one or more caches 2124 andmemory 2126. In accordance with an aspect of the present invention, andwith reference to FIG. 21B the write back logic includes the following:

REPEAT  if store queue not empty (2150)   If cache bus available forwrite (2152)     Select oldest SRQ element (2154)     IF (ELEMENTCorresponds to RR restoration request       && element address smallerthan stack pointer) (2156)       remove element from store queue withoutwriting (2158)    ELSE      write element to memory (2160)      Removeelement from store queue (2162)

While the logic shown hereinabove and in FIG. 21B is described withreference to a processor stack growing downwards, i.e., whereinaddresses smaller than the value of the stack pointer are not part ofthe stack (INQUIRY 2156), those skilled in the art will understand thatthe teachings herein may be adapted to architectures wherein theprocessor stack grows upwards, i.e., wherein addresses larger than astack pointer are not a part of the stack, e.g., by replacing the testfor “smaller” with a test for “greater” in the example write back logicpseudocode hereinabove and in INQUIRY 2156 of FIG. 21B.

In another embodiment, with reference to FIG. 21C, the write back logicincludes:

REPEAT  if store queue not empty (2180)   If cache bus available forwrite (2182)     Select oldest SRQ element (2184)      IF (ELEMENTCorresponds to RR restoration request         && corresponding registerrestore has completed)         (2186)          remove element from storequeue without writing          (2188)    ELSE       write element tomemory (2190)        Remove element from store queue (2192)

In one embodiment, the processing of FIGS. 21B-21C is performed inconjunction with the Spillm/Reloadm instructions, since thoseinstructions indicate that the buffer is not programmer accessible forwrites at a particular point in time (e.g., between store and load). Inanother embodiment, one or more instructions or other mechanisms areused to indicate that the storage buffer will no longer be accessedafter a load multiple state restore or after another selected point intime.

In yet other embodiments, data stored in the stack region (i.e., thosepages in the address space allocated for holding the stack) below thestack pointer are considered to be no longer used, and are suppressedduring write back from the store queue, and/or in responding to XIcross-interrogate requests. In such an embodiment, optimizations whereindata is allocated below the stack pointer are not permissible. Inanother embodiment supporting optimizations wherein data may beallocated below the stack pointer (e.g., in a region defined by an ABIsuch as the Power ELFv2 ABI, or the AMD Red Zone specification forLinux), the write back of data is suppressed when the data is writtenbeyond the defined region wherein data may be allocated and accessedbeyond the stack pointer, e.g., write back from a store queue may besuppressed for addresses more than 512 bytes below the stack pointer, inaccordance with, e.g., the Power ELFv2 ABI.

In a further aspect of the present invention, an alternative to theregister restoration snapshot may be used. This alternative is arecovery buffer, also referred to as a recovery file. In the case of amisprediction or an exception, the register values may be recovered fromthe recovery buffer rather than a snapshot. Each time a register isoverwritten, the old values are stored in a recovery file queue in casethey are needed for recovery. One example of such a recovery file isdepicted in FIG. 22A. In one example, a recovery file 2200 isimplemented as a queue, and includes one or more register recoveryvalues corresponding to executed instructions 2202. As an example,recovery buffer 2200 includes a plurality of registers 2204 having aregister number to be recovered, Rn, Rk, Rm, and so forth, and aregister value 2206 to be recovered. An instruction tag 2208 is assignedto each register 2204. The queue has a tail pointer 2209 pointing to therecovery register corresponding to the oldest instruction that may berolled back by recovering the value overwritten by the instruction, anda head pointer 2210 pointing to the recovery value corresponding to theyoungest instruction and indicating the position where additionalrecovery values will be inserted responsive to instructions beingexecuted.

In one aspect, a stored recovery value is associated with an instructionto restore. The stored value is overwritten by an instruction andrecovery is performed when the instruction is flushed. A state machinemay be provided in which for each flushed instruction, the value isrecovered from recovery buffer 2200 reading recovery values 2206corresponding to instructions. The state machine may have a forward orbackward scan.

Further details regarding the recovery buffer are described withreference to FIG. 22B. In one example, an instruction is fetched from aninstruction cache 2220 by an instruction fetch unit 2222 and decoded byan instruction decode unit 2224. Operands are obtained from one or moreregister files 2226. If a value from a register file is modified, it isstored in recovery buffer 2228 at the head of the recovery buffer. Oneor more execution units 2230 execute the instructions, and completionand recovery unit 2232 completes the instruction or if there is amisprediction or exception, processing proceeds to the recovery buffer2228 that walks backwards, in one example, copying each value to berestored from recovery buffer 2228 to register files 2226 until thein-order register state at the misprediction or exception point isrestored.

In accordance with one aspect of the present invention, the recoveryvalues stored in fast processor memory are used to restore valuesresponsive to a register restoration request corresponding to a loadmultiple, a coalesced load multiple sequence or Reloadm instructions.

In one example, when a register is overwritten, the old values arestored in the recovery buffer. During recovery, the values in therecovery buffer are copied back to the register file. In one example,the processor steps through the recovery buffer to retrieve the valuespresent at entry to the store multiple. As examples, the step throughthe recovery buffer to restore register values is performed via abackward scan or a forward scan. (In one particular example, the oldestrecovery entry successive to a save request for a specified register isrestored.) One example of the logic for a forward scan is indicatedbelow:

Retore [0...31] <= false Restore [LM range] <= true If NOT (STM tag inrecovery file)  ... special handling For i = STM tag to LM tag {  Rec <=RecFile[i]  If Restore[Rec.reg]  {   Reg[Rec.reg] <= Rec.value  Restore[rec.reg] <= false   } }

In accordance with the example hereinabove, Restore tracks for eachregister whether a register is still to be restored. It is initializedto restore all registers corresponding to the registers specified by theLoad Multiple (or Reloadm) instruction. If the tag of a correspondingStore Multiple (STM) from which the Load Multiple (LM) is to restore thestate cannot be located, special handling is performed. In at least oneembodiment, the special handling corresponds to loading values from thememory location specified in the Load Multiple or Reloadm instruction.

The pseudocode then scans forward through the recovery buffer startingat the recovery buffer entry corresponding to the tag of the registersave instruction (e.g., a STM Store Multiple or Spillm) up to theinstruction restoring registers (e.g., the Load Multiple or Reloadm).

For each entry, the recovery buffer entry is read (i.e., represented bythe value RecFile[ ]), consisting of at least the fields Rec.regindicating the register number (2204 of FIG. 22A) contained in theparticular recovery buffer entry and the value to be restored to theregister, Rec.value (field 2206 of FIG. 22A). If the registercorresponds to one of the registers of the Load Multiple or Reloadm, thefirst (oldest) value overwritten after the STM Store Multiple (Spillm)is restored.

Any remaining registers in Restore[ ] that have not been restored fromthe recovery buffer are restored from memory.

Similarly, for a backward scan, the logic includes: Restore [0...31] <=false Restore [LM range] <= trueIf NOT (STM tag in recovery file)  ...special handling For i = LM tag to STM tag { If Rec.reg in LM range { Reg[Rec.reg] <= Rec.value  Restore[rec.reg] <= false  }  }

In a further aspect, values beyond the recovery file tail may berecovered. This may be performed if the value has not been overwritten,which can be determined by comparing against a highwater mark of thehead/second tail that moves in response to the head overwriting the tailentries. If head is greater than or equal to the second tail, then thesecond tail is equal to the head.

As described herein, the actual state restored by exception and branchmisprediction recovery, as well as register restoration, is contained,in one example, in physical registers. To write to a new register, aphysical register is allocated, an architected register to be written tois mapped to the allocated physical register, and the physical registeris written. In accordance with an aspect of the present invention,physical registers are allocated responsive to register write requestsso as to maximize the utility of physical registers as a source forrestoring registers responsive to a register restoration request. Forinstance, the allocation technique for new registers from the physicalregister file is modified to give preference to selecting registers notassociated with a register restoration snapshot. Further, if a registeris to be obtained from a register restoration snapshot, in at least oneembodiment, a selection is made so as to minimize the performance impactby selecting a physical register which may not be a part of theregisters to be restored from a snapshot, or from a snapshot with theleast performance impact. In at least one embodiment, a snapshotcorresponding to the least performance impact is the oldest snapshot.This processing, in accordance with one or more aspects of the presentinvention, is further described with reference to FIGS. 23A-23B.

Referring to FIG. 23A, in one example, a determination is made as towhether an unused physical register is available, INQUIRY 2300. If anunused physical register is available, an unused register is selectedand allocated, STEP 2302. However, if an unused physical register is notavailable, then a register is selected, in accordance with an aspect ofthe present invention, STEP 2304. For instance, a register is selectedthat is not in an active snapshot for recovery (e.g., branchmisprediction, exception, etc.); i.e., a register used in registerrestoration snapshots, but not recovery snapshots. In one example, aregister is selected from the oldest snapshot, since, for instance, theoldest snapshot may be more likely to have a register ready to be freedand it may be less costly to take a register from an older snapshot,since it may not be used as soon as a register in a younger snapshot. Inanother embodiment, a register from a register restoration snapshot ischosen that does not correspond to a register to be restored, i.e., aregister outside the range of registers specified to be saved by the STMor Spillm instruction.

Further, the register may be marked as invalid in the snapshot, STEP2306, or the register restoration snapshot may be deallocated, STEP2308. When a register restoration snapshot is deallocated, the physicalregisters associated with that snapshot become available when they donot correspond to registers also used in another snapshot.

The selected register is then allocated, STEP 2310.

Another embodiment for allocating a register is described with referenceto FIG. 23B. In one example, a determination is made as to whether anunused physical register is available, INQUIRY 2330. If an unusedphysical register is available, an unused register is selected andallocated, STEP 2332. However, if an unused physical register is notavailable, then an oldest snapshot is selected, STEP 2334, and adetermination is made as to whether the selected snapshot is a registerrestoration snapshot, INQUIRY 2336. If it is a register restorationsnapshot, it is deallocated enabling the registers associated therewithto become available if they are not in another snapshot, STEP 2340.Processing continues to INQUIRY 2330.

Returning to INQUIRY 2336, if the selected snapshot is not a registerrestoration snapshot, processing waits for the oldest snapshot to becomeinactive, STEP 2338. Processing returns to INQUIRY 2330.

In other embodiments, instead of waiting for the oldest snapshot tobecome inactive, other snapshots may be checked. Further, a snapshotother than the oldest may initially be selected, in other embodiments.Many variations are possible.

As described herein, rename registers and rename maps (e.g., snapshots)may be used for implementing branch misprediction recovery and preciseexceptions. When an exception or a branch misprediction is discoveredthe in-order program state can be recovered from the register rename mapand the physical registers, and by flushing speculatively stored statein store queues (and possibly caches, e.g., for an embodiment usingtransactional memory). When an exception or branch misprediction can nolonger occur, because an instruction has committed, the register renamemaps and physical registers may be deallocated and reused.

In accordance with at least one embodiment, rename registers and renamemaps used for implementing branch misprediction recovery and preciseexceptions are also used to implement register restoration for savingand restoring program state, e.g., in the context of function calls, forrecovering caller and callee-saved registers in the caller and a callee,respectively.

Further, in accordance with one embodiment, register snapshots arecreated in order to implement branch misprediction recovery, andimplement precise exceptions in the presence of out-of-order execution.In one embodiment, additional snapshots are made for recoveringarchitected state using register restoration. However, holding suchregister snapshots for register restoration may cause an insufficientnumber of free registers to become available, stopping processors frommaking progress during execution when no new target registers can beexecuted.

Also, register restoration snapshots may be allocated, but recovery maynever occur. For example, structured C++/Java exception handling maycause a function to abort without ever restoring its state, orsetjump/longjump may similarly prevent a register restore to beencountered that may deallocate a register snapshot allocated forregister restoration.

In accordance with one embodiment, register snapshots are maintained ina separate queue, rename registers referenced in snapshots are preventedfrom being deallocated, and register snapshots may be recycled based onensuring a suitable supply of free registers. Thus, when the registerfreelist, i.e., the register rename pool used to satisfy new registerallocation requests, falls below a certain number of registers, registersnapshots may be deallocated until the freelist reaches the target size.The target size may be a fixed threshold, or based on an estimate of thenumber of new rename registers allocated by a current workload, possiblyweighted by the number of cycles needed to deallocate snapshots and makeavailable additional registers. (In one embodiment, that threshold maybe 0, and snapshots would only be deallocated to satisfy rename registerallocation requests. However, that policy may lead to resource stallswhile instructions are waiting for rename registers to becomeavailable.)

In one embodiment, register rename snapshots and their associatedregisters are deallocated and recycled into the rename freelist in theFIFO (first in, first out) policy, where the snapshot having beenallocated the earliest is also deallocated first. In another embodiment,register snapshots that have been used by register restoration are alsoimmediately deallocated—this may take particular advantage of the stackmodel used for function calls, where the most recently entered functionis exited first, and so its register restoration state may becomeavailable for deallocation first).

In another embodiment, only a single snapshot (or the last n, where n isa small integer, such as 2) corresponding to the most recent bulk saverequest is stored for register restoration. While this supports onlyregister restoration for a single function call, this offers the bestbenefit in terms of the relationship of gains achieved per designcomplexity, given that these are both dynamically the most frequent (inmany workloads, over 50% of function calls are leaf functions), and havethe biggest negative impact in terms of load/hit/store interlocksresulting in performance-degrading stall cycles.

In at least one embodiment, register snapshots for register restorationare captured under mask control, so that a snapshot may only contain theregisters listed by the Spilll/STM request, in order to prevent renameregisters from being unnecessarily prevented from reallocation.

In another embodiment, registers corresponding to register save/restoresequences that may be listed in register rename map snapshots made forregister restoration are not independently retained. Instead, renameregisters are deallocated based on their use for implementing branchmisprediction recovery and precise exceptions. When registers are nolonger needed, they are returned to the freelist pool (e.g., inaccordance with an implementation, such as that of Buti et al.)

In one embodiment, the freelist selection algorithm is modified toselect registers from the freelist which are not referenced by aregister restoration snapshot. In another embodiment, the freelistselection algorithm is modified to select registers from the freelistwhich were allocated to a register rename snapshot earlier than otherrename registers. In yet another embodiment, the freelist selectionalgorithm is modified to select registers from the freelist which arenot referenced by an active register rename snapshot (i.e., for exampleexcluding most recently allocated snapshots that have already been usedto restore the register state, e.g., for a corresponding function). Inyet another embodiment, a combination of any of these three criteria andadditional criteria may be used. In yet another embodiment, acombination of all of these three criteria and additional criteria maybe used. Other possibilities also exist.

Described herein are various aspects and embodiments of registerrestoration processing. Although a number of examples and techniques areprovided, variations and/or additions may be made without departing froma spirit of aspects of the present invention.

One or more aspects of the present invention are inextricably tied tocomputer technology and facilitate processing within a computer,improving performance thereof. Further details of one embodiment offacilitating processing within a computing environment, as it relates toone or more aspects of the present invention, are described withreference to FIGS. 24A-24B.

Referring to FIG. 24A, in one embodiment, a load request to restore aplurality of architected registers is obtained by a processor (2400).Based on obtaining the load request, one or more architected registersof the plurality of architected registers are restored (2402). Therestoring includes, e.g., using a snapshot that maps architectedregisters to physical registers to replace one or more physicalregisters currently assigned to the one or more architected registerswith one or more physical registers of the snapshot corresponding to theone or more architected registers (2404). In one example, the one ormore architected registers are restored without a copying of values forthe one or more architected registers from memory (2406).

In one embodiment, based on obtaining the load request, a determinationis made as to whether a snapshot corresponding to the one or morearchitected registers is available (2408). Based on the determiningindicating the snapshot is available, the restoring is performed usingthe snapshot (2410).

Further, in one example, based on the determining indicating a snapshotcorresponding to the one or more architected registers is unavailable,the one or more architected registers are restored by loading valuesfrom memory into the one or more architected registers (2412).

Referring to FIG. 24B, in one embodiment, the determining whether asnapshot is available includes using a snapshot stack to determinewhether a snapshot corresponding to the one or more architectedregisters is available (2420). In one example, the snapshot stackincludes a plurality of entries (2422), and an entry of the snapshotstack includes a snapshot identifier identifying the snapshot (2424). Infurther examples, the entry of the snapshot stack may include additionalinformation including at least one of an address in memory of contentsof the one or more architected registers, an indication of the one ormore architected registers associated with the snapshot, and/or avalidity indicator indicating whether the snapshot is valid (2426).

In a further aspect, the snapshot is created to save a mapping of theone or more physical registers to the one or more architected registers(2428). The creating the snapshot is performed, e.g., based on obtaininga save request requesting a saving of the one or more architectedregisters (2430).

In examples, the load request includes a load multiple instruction, andthe save request includes a store multiple instruction (2432).

Many variations are possible without departing from a spirit of aspectsof the present invention. It should be noted that numerous aspects andfeatures are described herein, and unless otherwise inconsistent, eachaspect or feature may be combinable with any other aspect or feature.

Other types of computing environments may also incorporate and use oneor more aspects of the present invention, including, but not limited to,emulation environments, an example of which is described with referenceto FIG. 25A. In this example, a computing environment 2500 includes, forinstance, a native central processing unit (CPU) 2502, a memory 2504,and one or more input/output devices and/or interfaces 2506 coupled toone another via, for example, one or more buses 2508 and/or otherconnections. As examples, computing environment 2500 may include aPowerPC processor or a pSeries server offered by International BusinessMachines Corporation, Armonk, N.Y.; and/or other machines based onarchitectures offered by International Business Machines Corporation,Intel, or other companies.

Native central processing unit 2502 includes one or more nativeregisters 2510, such as one or more general purpose registers and/or oneor more special purpose registers used during processing within theenvironment. These registers include information that represents thestate of the environment at any particular point in time.

Moreover, native central processing unit 2502 executes instructions andcode that are stored in memory 2504. In one particular example, thecentral processing unit executes emulator code 2512 stored in memory2504. This code enables the computing environment configured in onearchitecture to emulate another architecture. For instance, emulatorcode 2512 allows machines based on architectures other than thez/Architecture, such as PowerPC processors, pSeries servers, or otherservers or processors, to emulate the z/Architecture and to executesoftware and instructions developed based on the z/Architecture.

Further details relating to emulator code 2512 are described withreference to FIG. 25B. Guest instructions 2550 stored in memory 2504comprise software instructions (e.g., correlating to machineinstructions) that were developed to be executed in an architectureother than that of native CPU 2502. For example, guest instructions 2550may have been designed to execute on a z/Architecture processor, butinstead, are being emulated on native CPU 2502, which may be, forexample, an Intel processor. In one example, emulator code 2512 includesan instruction fetching routine 2552 to obtain one or more guestinstructions 2550 from memory 2504, and to optionally provide localbuffering for the instructions obtained. It also includes an instructiontranslation routine 2554 to determine the type of guest instruction thathas been obtained and to translate the guest instruction into one ormore corresponding native instructions 2556. This translation includes,for instance, identifying the function to be performed by the guestinstruction and choosing the native instruction(s) to perform thatfunction.

Further, emulator code 2512 includes an emulation control routine 2560to cause the native instructions to be executed. Emulation controlroutine 2560 may cause native CPU 2502 to execute a routine of nativeinstructions that emulate one or more previously obtained guestinstructions and, at the conclusion of such execution, return control tothe instruction fetch routine to emulate the obtaining of the next guestinstruction or a group of guest instructions. Execution of nativeinstructions 2556 may include loading data into a register from memory2504; storing data back to memory from a register; or performing sometype of arithmetic or logic operation, as determined by the translationroutine.

Each routine is, for instance, implemented in software, which is storedin memory and executed by native central processing unit 2502. In otherexamples, one or more of the routines or operations are implemented infirmware, hardware, software or some combination thereof. The registersof the emulated processor may be emulated using registers 2510 of thenative CPU or by using locations in memory 2504. In embodiments, guestinstructions 2550, native instructions 2556 and emulator code 2512 mayreside in the same memory or may be disbursed among different memorydevices.

As used herein, firmware includes, e.g., the microcode or Millicode ofthe processor. It includes, for instance, the hardware-levelinstructions and/or data structures used in implementation of higherlevel machine code. In one embodiment, it includes, for instance,proprietary code that is typically delivered as microcode that includestrusted software or microcode specific to the underlying hardware andcontrols operating system access to the system hardware.

A guest instruction 2550 that is obtained, translated and executed is,for instance, one of the instructions described herein. The instruction,which is of one architecture (e.g., the z/Architecture), is fetched frommemory, translated and represented as a sequence of native instructions2556 of another architecture (e.g., PowerPC, pSeries, Intel, etc.).These native instructions are then executed.

One or more aspects may relate to cloud computing.

It is understood in advance that although this disclosure includes adetailed description on cloud computing, implementation of the teachingsrecited herein are not limited to a cloud computing environment. Rather,embodiments of the present invention are capable of being implemented inconjunction with any other type of computing environment now known orlater developed.

Cloud computing is a model of service delivery for enabling convenient,on-demand network access to a shared pool of configurable computingresources (e.g. networks, network bandwidth, servers, processing,memory, storage, applications, virtual machines, and services) that canbe rapidly provisioned and released with minimal management effort orinteraction with a provider of the service. This cloud model may includeat least five characteristics, at least three service models, and atleast four deployment models.

Characteristics are as follows:

On-demand self-service: a cloud consumer can unilaterally provisioncomputing capabilities, such as server time and network storage, asneeded automatically without requiring human interaction with theservice's provider.

Broad network access: capabilities are available over a network andaccessed through standard mechanisms that promote use by heterogeneousthin or thick client platforms (e.g., mobile phones, laptops, and PDAs).

Resource pooling: the provider's computing resources are pooled to servemultiple consumers using a multi-tenant model, with different physicaland virtual resources dynamically assigned and reassigned according todemand. There is a sense of location independence in that the consumergenerally has no control or knowledge over the exact location of theprovided resources but may be able to specify location at a higher levelof abstraction (e.g., country, state, or datacenter).

Rapid elasticity: capabilities can be rapidly and elasticallyprovisioned, in some cases automatically, to quickly scale out andrapidly released to quickly scale in. To the consumer, the capabilitiesavailable for provisioning often appear to be unlimited and can bepurchased in any quantity at any time.

Measured service: cloud systems automatically control and optimizeresource use by leveraging a metering capability at some level ofabstraction appropriate to the type of service (e.g., storage,processing, bandwidth, and active user accounts). Resource usage can bemonitored, controlled, and reported providing transparency for both theprovider and consumer of the utilized service.

Service Models are as follows:

Software as a Service (SaaS): the capability provided to the consumer isto use the provider's applications running on a cloud infrastructure.The applications are accessible from various client devices through athin client interface such as a web browser (e.g., web-based email). Theconsumer does not manage or control the underlying cloud infrastructureincluding network, servers, operating systems, storage, or evenindividual application capabilities, with the possible exception oflimited user-specific application configuration settings.

Platform as a Service (PaaS): the capability provided to the consumer isto deploy onto the cloud infrastructure consumer-created or acquiredapplications created using programming languages and tools supported bythe provider. The consumer does not manage or control the underlyingcloud infrastructure including networks, servers, operating systems, orstorage, but has control over the deployed applications and possiblyapplication hosting environment configurations.

Infrastructure as a Service (IaaS): the capability provided to theconsumer is to provision processing, storage, networks, and otherfundamental computing resources where the consumer is able to deploy andrun arbitrary software, which can include operating systems andapplications. The consumer does not manage or control the underlyingcloud infrastructure but has control over operating systems, storage,deployed applications, and possibly limited control of select networkingcomponents (e.g., host firewalls).

Deployment Models are as follows:

Private cloud: the cloud infrastructure is operated solely for anorganization. It may be managed by the organization or a third party andmay exist on-premises or off-premises.

Community cloud: the cloud infrastructure is shared by severalorganizations and supports a specific community that has shared concerns(e.g., mission, security requirements, policy, and complianceconsiderations). It may be managed by the organizations or a third partyand may exist on-premises or off-premises.

Public cloud: the cloud infrastructure is made available to the generalpublic or a large industry group and is owned by an organization sellingcloud services.

Hybrid cloud: the cloud infrastructure is a composition of two or moreclouds (private, community, or public) that remain unique entities butare bound together by standardized or proprietary technology thatenables data and application portability (e.g., cloud bursting forloadbalancing between clouds).

A cloud computing environment is service oriented with a focus onstatelessness, low coupling, modularity, and semantic interoperability.At the heart of cloud computing is an infrastructure comprising anetwork of interconnected nodes.

Referring now to FIG. 26, illustrative cloud computing environment 50 isdepicted. As shown, cloud computing environment 50 comprises one or morecloud computing nodes 10 with which local computing devices used bycloud consumers, such as, for example, personal digital assistant (PDA)or cellular telephone 54A, desktop computer 54B, laptop computer 54C,and/or automobile computer system 54N may communicate. Nodes 10 maycommunicate with one another. They may be grouped (not shown) physicallyor virtually, in one or more networks, such as Private, Community,Public, or Hybrid clouds as described hereinabove, or a combinationthereof. This allows cloud computing environment 50 to offerinfrastructure, platforms and/or software as services for which a cloudconsumer does not need to maintain resources on a local computingdevice. It is understood that the types of computing devices 54A-N shownin FIG. 26 are intended to be illustrative only and that computing nodes10 and cloud computing environment 50 can communicate with any type ofcomputerized device over any type of network and/or network addressableconnection (e.g., using a web browser).

Referring now to FIG. 27, a set of functional abstraction layersprovided by cloud computing environment 50 (FIG. 26) is shown. It shouldbe understood in advance that the components, layers, and functionsshown in FIG. 27 are intended to be illustrative only and embodiments ofthe invention are not limited thereto. As depicted, the following layersand corresponding functions are provided:

Hardware and software layer 60 includes hardware and softwarecomponents. Examples of hardware components include mainframes 61; RISC(Reduced Instruction Set Computer) architecture based servers 62;servers 63; blade servers 64; storage devices 65; and networks andnetworking components 66. In some embodiments, software componentsinclude network application server software 67 and database software 68.

Virtualization layer 70 provides an abstraction layer from which thefollowing examples of virtual entities may be provided: virtual servers71; virtual storage 72; virtual networks 73, including virtual privatenetworks; virtual applications and operating systems 74; and virtualclients 75.

In one example, management layer 80 may provide the functions describedbelow. Resource provisioning 81 provides dynamic procurement ofcomputing resources and other resources that are utilized to performtasks within the cloud computing environment. Metering and Pricing 82provide cost tracking as resources are utilized within the cloudcomputing environment, and billing or invoicing for consumption of theseresources. In one example, these resources may comprise applicationsoftware licenses. Security provides identity verification for cloudconsumers and tasks, as well as protection for data and other resources.User portal 83 provides access to the cloud computing environment forconsumers and system administrators. Service level management 84provides cloud computing resource allocation and management such thatrequired service levels are met. Service Level Agreement (SLA) planningand fulfillment 85 provides pre-arrangement for, and procurement of,cloud computing resources for which a future requirement is anticipatedin accordance with an SLA.

Workloads layer 90 provides examples of functionality for which thecloud computing environment may be utilized. Examples of workloads andfunctions which may be provided from this layer include: mapping andnavigation 91; software development and lifecycle management 92; virtualclassroom education delivery 93; data analytics processing 94;transaction processing 95; and register restoration and associatedprocessing 96.

The present invention may be a system, a method, and/or a computerprogram product at any possible technical detail level of integration.The computer program product may include a computer readable storagemedium (or media) having computer readable program instructions thereonfor causing a processor to carry out aspects of the present invention.

The computer readable storage medium can be a tangible device that canretain and store instructions for use by an instruction executiondevice. The computer readable storage medium may be, for example, but isnot limited to, an electronic storage device, a magnetic storage device,an optical storage device, an electromagnetic storage device, asemiconductor storage device, or any suitable combination of theforegoing. A non-exhaustive list of more specific examples of thecomputer readable storage medium includes the following: a portablecomputer diskette, a hard disk, a random access memory (RAM), aread-only memory (ROM), an erasable programmable read-only memory (EPROMor Flash memory), a static random access memory (SRAM), a portablecompact disc read-only memory (CD-ROM), a digital versatile disk (DVD),a memory stick, a floppy disk, a mechanically encoded device such aspunch-cards or raised structures in a groove having instructionsrecorded thereon, and any suitable combination of the foregoing. Acomputer readable storage medium, as used herein, is not to be construedas being transitory signals per se, such as radio waves or other freelypropagating electromagnetic waves, electromagnetic waves propagatingthrough a waveguide or other transmission media (e.g., light pulsespassing through a fiber-optic cable), or electrical signals transmittedthrough a wire.

Computer readable program instructions described herein can bedownloaded to respective computing/processing devices from a computerreadable storage medium or to an external computer or external storagedevice via a network, for example, the Internet, a local area network, awide area network and/or a wireless network. The network may comprisecopper transmission cables, optical transmission fibers, wirelesstransmission, routers, firewalls, switches, gateway computers and/oredge servers. A network adapter card or network interface in eachcomputing/processing device receives computer readable programinstructions from the network and forwards the computer readable programinstructions for storage in a computer readable storage medium withinthe respective computing/processing device.

Computer readable program instructions for carrying out operations ofthe present invention may be assembler instructions,instruction-set-architecture (ISA) instructions, machine instructions,machine dependent instructions, microcode, firmware instructions,state-setting data, configuration data for integrated circuitry, oreither source code or object code written in any combination of one ormore programming languages, including an object oriented programminglanguage such as Smalltalk, C++, or the like, and procedural programminglanguages, such as the “C” programming language or similar programminglanguages. The computer readable program instructions may executeentirely on the user's computer, partly on the user's computer, as astand-alone software package, partly on the user's computer and partlyon a remote computer or entirely on the remote computer or server. Inthe latter scenario, the remote computer may be connected to the user'scomputer through any type of network, including a local area network(LAN) or a wide area network (WAN), or the connection may be made to anexternal computer (for example, through the Internet using an InternetService Provider). In some embodiments, electronic circuitry including,for example, programmable logic circuitry, field-programmable gatearrays (FPGA), or programmable logic arrays (PLA) may execute thecomputer readable program instructions by utilizing state information ofthe computer readable program instructions to personalize the electroniccircuitry, in order to perform aspects of the present invention.

Aspects of the present invention are described herein with reference toflowchart illustrations and/or block diagrams of methods, apparatus(systems), and computer program products according to embodiments of theinvention. It will be understood that each block of the flowchartillustrations and/or block diagrams, and combinations of blocks in theflowchart illustrations and/or block diagrams, can be implemented bycomputer readable program instructions.

These computer readable program instructions may be provided to aprocessor of a general purpose computer, special purpose computer, orother programmable data processing apparatus to produce a machine, suchthat the instructions, which execute via the processor of the computeror other programmable data processing apparatus, create means forimplementing the functions/acts specified in the flowchart and/or blockdiagram block or blocks. These computer readable program instructionsmay also be stored in a computer readable storage medium that can directa computer, a programmable data processing apparatus, and/or otherdevices to function in a particular manner, such that the computerreadable storage medium having instructions stored therein comprises anarticle of manufacture including instructions which implement aspects ofthe function/act specified in the flowchart and/or block diagram blockor blocks.

The computer readable program instructions may also be loaded onto acomputer, other programmable data processing apparatus, or other deviceto cause a series of operational steps to be performed on the computer,other programmable apparatus or other device to produce a computerimplemented process, such that the instructions which execute on thecomputer, other programmable apparatus, or other device implement thefunctions/acts specified in the flowchart and/or block diagram block orblocks.

The flowchart and block diagrams in the Figures illustrate thearchitecture, functionality, and operation of possible implementationsof systems, methods, and computer program products according to variousembodiments of the present invention. In this regard, each block in theflowchart or block diagrams may represent a module, segment, or portionof instructions, which comprises one or more executable instructions forimplementing the specified logical function(s). In some alternativeimplementations, the functions noted in the block may occur out of theorder noted in the figures. For example, two blocks shown in successionmay, in fact, be executed substantially concurrently, or the blocks maysometimes be executed in the reverse order, depending upon thefunctionality involved. It will also be noted that each block of theblock diagrams and/or flowchart illustration, and combinations of blocksin the block diagrams and/or flowchart illustration, can be implementedby special purpose hardware-based systems that perform the specifiedfunctions or acts or carry out combinations of special purpose hardwareand computer instructions.

In addition to the above, one or more aspects may be provided, offered,deployed, managed, serviced, etc. by a service provider who offersmanagement of customer environments. For instance, the service providercan create, maintain, support, etc. computer code and/or a computerinfrastructure that performs one or more aspects for one or morecustomers. In return, the service provider may receive payment from thecustomer under a subscription and/or fee agreement, as examples.Additionally or alternatively, the service provider may receive paymentfrom the sale of advertising content to one or more third parties.

In one aspect, an application may be deployed for performing one or moreembodiments. As one example, the deploying of an application comprisesproviding computer infrastructure operable to perform one or moreembodiments.

As a further aspect, a computing infrastructure may be deployedcomprising integrating computer readable code into a computing system,in which the code in combination with the computing system is capable ofperforming one or more embodiments.

As yet a further aspect, a process for integrating computinginfrastructure comprising integrating computer readable code into acomputer system may be provided. The computer system comprises acomputer readable medium, in which the computer medium comprises one ormore embodiments. The code in combination with the computer system iscapable of performing one or more embodiments.

Although various embodiments are described above, these are onlyexamples. For example, computing environments of other architectures canbe used to incorporate and use one or more embodiments. Further,different instructions, instruction formats, instruction fields and/orinstruction values may be used. Many variations are possible.

Further, other types of computing environments can benefit and be used.As an example, a data processing system suitable for storing and/orexecuting program code is usable that includes at least two processorscoupled directly or indirectly to memory elements through a system bus.The memory elements include, for instance, local memory employed duringactual execution of the program code, bulk storage, and cache memorywhich provide temporary storage of at least some program code in orderto reduce the number of times code must be retrieved from bulk storageduring execution.

Input/Output or I/O devices (including, but not limited to, keyboards,displays, pointing devices, DASD, tape, CDs, DVDs, thumb drives andother memory media, etc.) can be coupled to the system either directlyor through intervening I/O controllers. Network adapters may also becoupled to the system to enable the data processing system to becomecoupled to other data processing systems or remote printers or storagedevices through intervening private or public networks. Modems, cablemodems, and Ethernet cards are just a few of the available types ofnetwork adapters.

The terminology used herein is for the purpose of describing particularembodiments only and is not intended to be limiting. As used herein, thesingular forms “a”, “an” and “the” are intended to include the pluralforms as well, unless the context clearly indicates otherwise. It willbe further understood that the terms “comprises” and/or “comprising”,when used in this specification, specify the presence of statedfeatures, integers, steps, operations, elements, and/or components, butdo not preclude the presence or addition of one or more other features,integers, steps, operations, elements, components and/or groups thereof.

The corresponding structures, materials, acts, and equivalents of allmeans or step plus function elements in the claims below, if any, areintended to include any structure, material, or act for performing thefunction in combination with other claimed elements as specificallyclaimed. The description of one or more embodiments has been presentedfor purposes of illustration and description, but is not intended to beexhaustive or limited to in the form disclosed. Many modifications andvariations will be apparent to those of ordinary skill in the art. Theembodiment was chosen and described in order to best explain variousaspects and the practical application, and to enable others of ordinaryskill in the art to understand various embodiments with variousmodifications as are suited to the particular use contemplated.

What is claimed is:
 1. A computer program product for facilitatingprocessing within a computing environment, the computer program productcomprising: a computer readable storage medium readable by a processingcircuit and storing instructions for performing a method comprising:obtaining a load request to restore a plurality of architectedregisters; and restoring, based on obtaining the load request, one ormore architected registers of the plurality of architected registers,wherein the restoring uses a snapshot that maps architected registers tophysical registers to replace one or more physical registers currentlyassigned to the one or more architected registers with one or morephysical registers of the snapshot corresponding to the one or morearchitected registers.
 2. The computer program product of claim 1,wherein the method further comprises: determining, based on obtainingthe load request, whether a snapshot corresponding to the one or morearchitected registers is available; and performing the restoring usingthe snapshot, based on the determining indicating the snapshot isavailable.
 3. The computer program product of claim 2, wherein themethod further comprises: restoring the one or more architectedregisters by loading values from memory into the one or more architectedregisters, based on the determining indicating a snapshot correspondingto the one or more architected registers is unavailable.
 4. The computerprogram product of claim 2, wherein the determining comprises using asnapshot stack to determine whether a snapshot corresponding to the oneor more architected registers is available.
 5. The computer programproduct of claim 4, wherein the snapshot stack includes a plurality ofentries, and wherein an entry of the snapshot stack includes a snapshotidentifier identifying the snapshot.
 6. The computer program product ofclaim 5, wherein the entry of the snapshot stack includes additionalinformation including at least one selected from a group consisting of:an address in memory of contents of the one or more architectedregisters, an indication of the one or more architected registersassociated with the snapshot, and a validity indicator indicatingwhether the snapshot is valid.
 7. The computer program product of claim1, wherein the method further comprises creating the snapshot to save amapping of the one or more physical registers to the one or morearchitected registers.
 8. The computer program product of claim 7,wherein the creating the snapshot is performed based on obtaining a saverequest requesting a saving of the one or more architected registers. 9.The computer program product of claim 8, wherein the load requestcomprises a load multiple instruction, and the save request comprises astore multiple instruction.
 10. The computer program product of claim 1,wherein the one or more architected registers are restored without acopying of values for the one or more architected registers from memory.11. A computer system for facilitating processing within a computingenvironment, the computer system comprising: a memory; and a processorin communication with the memory, wherein the computer system isconfigured to perform a method, said method comprising: obtaining a loadrequest to restore a plurality of architected registers; and restoring,based on obtaining the load request, one or more architected registersof the plurality of architected registers, wherein the restoring uses asnapshot that maps architected registers to physical registers toreplace one or more physical registers currently assigned to the one ormore architected registers with one or more physical registers of thesnapshot corresponding to the one or more architected registers.
 12. Thecomputer system of claim 11, wherein the method further comprises:determining, based on obtaining the load request, whether a snapshotcorresponding to the one or more architected registers is available; andperforming the restoring using the snapshot, based on the determiningindicating the snapshot is available.
 13. The computer system of claim12, wherein the method further comprises: restoring the one or morearchitected registers by loading values from memory into the one or morearchitected registers, based on the determining indicating a snapshotcorresponding to the one or more architected registers is unavailable.14. The computer system of claim 12, wherein the determining comprisesusing a snapshot stack to determine whether a snapshot corresponding tothe one or more architected registers is available.
 15. The computersystem of claim 11, wherein the one or more architected registers arerestored without a copying of values for the one or more architectedregisters from memory.
 16. A computer-implemented method of facilitatingprocessing within a computing environment, the computer-implementedmethod comprising: obtaining, by a processor, a load request to restorea plurality of architected registers; and restoring, based on obtainingthe load request, one or more architected registers of the plurality ofarchitected registers, wherein the restoring uses a snapshot that mapsarchitected registers to physical registers to replace one or morephysical registers currently assigned to the one or more architectedregisters with one or more physical registers of the snapshotcorresponding to the one or more architected registers.
 17. Thecomputer-implemented method of claim 16, further comprising:determining, based on obtaining the load request, whether a snapshotcorresponding to the one or more architected registers is available; andperforming the restoring using the snapshot, based on the determiningindicating the snapshot is available.
 18. The computer-implementedmethod of claim 17, further comprising: restoring the one or morearchitected registers by loading values from memory into the one or morearchitected registers, based on the determining indicating a snapshotcorresponding to the one or more architected registers is unavailable.19. The computer-implemented method of claim 17, wherein the determiningcomprises using a snapshot stack to determine whether a snapshotcorresponding to the one or more architected registers is available. 20.The computer-implemented method of claim 16, wherein the one or morearchitected registers are restored without a copying of values for theone or more architected registers from memory.